无法通过Upstart启动Golang程序。

huangapple go评论102阅读模式
英文:

Can't Start Golang Prog Via Upstart

问题

我无法通过upstart运行我的golang程序。

这是我的项目目录--

 /go
   /src
     /print.io
       /geo
         main.go
       /geodomain
         [.. 文件 ..]

我将我的gopath设置为上面的/go目录。

/geo文件夹中,我可以运行go run main.go,它可以正常工作。

然而,使用以下upstart配置时,它会记录main.go:8:2: import "print.io/geodomain": cannot find package--

为什么当我手动运行命令时,它可以工作,但是通过upstart却不行?

description "go-server"
author "micah smith"

start on (net-device-up
          and local-filesystems
          and runlevel [2345])

stop on runlevel [!2345]
respawn

script
        chdir ~/go/src/print.io/geo/
        exec go run main.go
end script
英文:

I can't get my golang prog to run via upstart.

Here is my proj dir--

 /go
   /src
     /print.io
       /geo
         main.go
       /geodomain
         [.. files ..]

I have my gopath set to the /go dir above.

Within the /geo folder i can run go run main.go and it works.

However, with the following upstart configuration its logging main.go:8:2: import "print.io/geodomain": cannot find package--

Why doesnt it work from upstart like it does when i run the command manually?

description "go-server"
author "micah smith"

start on (net-device-up
          and local-filesystems
          and runlevel [2345])

stop on runlevel [!2345]
respawn

script
        chdir ~/go/src/print.io/geo/
        exec go run main.go
end script

答案1

得分: 2

从评论中重新提交:

> 当通过Upstart调用时,GOPATH是否可能未设置?尝试编译您的程序(go build)并将其放在正常的PATH上。

英文:

Resumbitted from comment:

> Is it possible that, when invoked through Upstart, the GOPATH isn't set? Try compiling your program (go build) and putting it on your normal PATH.

huangapple
  • 本文由 发表于 2013年10月1日 03:36:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/19102349.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定