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

4
build.sh → install.sh

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