douliandan7340 2016-07-04 05:54
浏览 35
已采纳

如何启动golang应用程序的暴发户进程?

I am using upstart to start my golang application. I have my application folder structure like this,

   web-app/
         /app
             main.go

I built the application as below,

$cd /home/ec2-user/go/src/github.com/dineshappavoo/web-app/app/
$go build ./...

It generated the binary app

And placed the web-app.conf in /etc/init/ folder. Here is the web-app.conf content,

#Web app upstart script
description "start and stop web app"

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

stop on runlevel [016]

respawn
respawn limit 5 30

console output

script
    chdir /home/ec2-user/go/src/github.com/dineshappavoo/web-app/app
    exec ./app
end script

When I tried sudo initctl list, it lists the process as stop/waiting. And I tried to start the process

$sudo initctl start web-app

It shows the process as start/running. But it is not started.

I checked the /var/log/messages logs. It shows,

init: web-app main process (18740) terminated with status 127

I couldn't start the process. I think there is some issue with the chdir. I tried different options for past two days. And I am fairly new to upstart but no luck. Could someone help me with this?

  • 写回答

1条回答 默认 最新

  • 普通网友 2016-07-06 00:26
    关注

    OP eventually solved after fixing a few issues. See comments, notably:

    • upstart might not recognise environment variables
    • Amazon Linux Image currently uses an old version of init (upstart 0.6.5), lacking newer features such as console log & nested script tags

    • status 127 can occur if exec can't find the binary

    • status 1 can occur if binary runs but fails
    • substituting a simple program in an upstart script can help diagnose errors
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器