简体   繁体   English

由Foreman导出的新贵脚本无法正常工作,重新生成速度太快

[英]Upstart script exported by Foreman not working properly, respawning too fast

The only error I could find out was looking at dmesg 我唯一能发现的错误是看dmesg

[  603.598951] init: thx4-web-1 main process ended, respawning
[  603.607935] init: thx4-web-1 main process (3901) terminated with status 127
[  603.607988] init: thx4-web-1 main process ended, respawning
[  603.616866] init: thx4-web-1 main process (3903) terminated with status 127
[  603.616917] init: thx4-web-1 respawning too fast, stopped

OS: Debian 7 , chruby (2.1.2), upstart (1.6.1-1) and foreman (0.74.0) 操作系统:Debian 7,chruby(2.1.2),暴发户(1.6.1-1)和领班(0.74.0)

Only one process, to simplify the debug process in Procfile.staging : 仅一个过程,以简化Procfile.staging中的调试过程:

web: RAILS_ENV=staging bundle exec puma -e staging -C config/puma.rb

Generated files by foreman: 工头生成的文件:

# /etc/init/thx4.conf
start on runlevel [2345]
stop on runlevel [!2345]

# /etc/init/thx4-web.conf
start on starting thx4
stop on stopping thx4

# /etc/init/thx4-web-1.conf
start on starting thx4-web
stop on stopping thx4-web
respawn
env PORT=5000
setuid deployer
chdir /home/deployer/apps/thx4/releases/20140707183433
exec RAILS_ENV=staging bundle exec puma -e staging -C config/puma.rb

When i run $ foreman start -f Procfile.staging inside app folder, all it works fine. 当我在应用程序文件夹中运行$ foreman start -f Procfile.staging ,一切正常。

Upstart logs your service execution in a log file by the same name in /var/log/upstart/your-service-name.log. Upstart将您的服务执行记录在/var/log/upstart/your-service-name.log中的同名日志文件中。 It should be helpful. 应该会有所帮助。

If you want to control respawn interval, add something like this right after the "respawn" line": 如果要控制重生间隔,请在“ respawn”行之后添加以下内容:

# Please note that you need both "respawn" and "respawn limit".
# The second line will attempt to respawn no more than 3 times, 
# waiting 5 seconds between respawns.
respawn
respawn limit 3 5

However, I don't think this will help. 但是,我认为这不会有所帮助。 Bash status code 127 means "command not found". Bash状态代码127表示“找不到命令”。 Perhaps your gems aren't set up properly for this environment? 也许您的宝石没有在这种环境下正确设置?

You can find more details about error #127 in this SO answer . 您可以在此SO答案中找到有关错误#127的更多详细信息。

How I solved: 我如何解决:

I created a .env file inside project root 我在项目根目录下创建了一个.env文件

# .env
PATH=/home/user/.gem/ruby/2.1.2/bin:/home/user/.rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/bin:/home/user/.rubies/ruby-2.1.2/bin:
RAILS_ENV=staging

# Procfile
web: bundle exec puma -e staging -C config/puma.rb

Exported file: 导出文件:

# /etc/init/app-web-1.conf
start on starting app-web
stop on stopping app-web
respawn

env PORT=5000
env PATH='/home/user/.gem/ruby/2.1.2/bin:/home/user/.rubies/ruby-2.1.2/lib/ruby/gems/2.1.0/bin:/home/user/.rubies/ruby-2.1.2/bin'
env RAILS_ENV='staging'

setuid user

chdir /home/user/apps/app/releases/20140709064220

exec bundle exec puma -e staging -C config/puma.rb

Important I had to install gem bundler as root (i don't know), like i did with foreman here: https://github.com/postmodern/chruby/issues/276 $ sudo chruby-exec ruby-2.1.2 -- gem install bundler 重要的是我必须以root身份安装gem bundler(我不知道),就像我在这里用工头一样: https : //github.com/postmodern/chruby/issues/276 $ sudo chruby-exec ruby-2.1.2 -- gem install bundler

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM