无法通过 Upstart 启动 Golang Prog [英] Can't Start Golang Prog Via Upstart

查看:33
本文介绍了无法通过 Upstart 启动 Golang Prog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过 upstart 运行我的 golang prog.

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

这是我的项目目录--

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

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

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

/geo 文件夹中,我可以运行 go run main.go 并且它可以工作.

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

但是,使用以下新贵配置,其日志记录 main.go:8:2: import "print.io/geodomain": cannot find package--

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

推荐答案

从评论中恢复:

是否有可能在通过 Upstart 调用时未设置 GOPATH?尝试编译您的程序(go build)并将其放在您的普通 PATH 中.

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.

这篇关于无法通过 Upstart 启动 Golang Prog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆