Browse Source

bug fixed

pull/103/head
Lunny Xiao 11 years ago
parent
commit
41fd7e4438
  1. 23
      cmd/serve.go
  2. 4
      install.sh

23
cmd/serve.go

@ -26,7 +26,8 @@ import (
"net/http"
"net/url"
"os"
"path"
"os/exec"
"path/filepath"
"strconv"
"strings"
)
@ -73,6 +74,15 @@ func autoPort() string {
return "8991"
}
func exePath() (string, error) {
file, err := exec.LookPath(os.Args[0])
if err != nil {
return "", err
}
return filepath.Abs(file)
}
// search packages
func runServe(cmd *Command, args []string) {
// Check flags.
@ -318,7 +328,11 @@ func AutoRun() error {
Files: []*os.File{nil, nil, nil},
}
p := path.Join(curPath, "gopm")
p, err := exePath()
if err != nil {
return err
}
_, err = os.StartProcess(p, []string{"gopm", "serve", "-l"}, attr)
if err != nil {
return err
@ -376,8 +390,9 @@ func getPidPath() (string, error) {
return "", err
}
pFile := strings.Replace("~/.gopm/var/pid", "~", homeDir, -1)
return pFile, nil
pFile := strings.Replace("~/.gopm/var/", "~", homeDir, -1)
os.MkdirAll(pFile, os.ModePerm)
return pFile + "pid", nil
}
func startService(listen, port string) error {

4
build.sh → install.sh

@ -1,6 +1,6 @@
#!/usr/bin/env bash
if [ ! -f build.sh ]; then
if [ ! -f install.sh ]; then
echo 'build.sh must be run within its container folder' 1>&2
exit 1
fi
@ -14,7 +14,7 @@ fi
gofmt -w $CURDIR
cd $NEWPATH
go build
go install
cd $CURDIR
echo 'Build successfully!'
Loading…
Cancel
Save