由于unicorn_rails抱怨不同的gem版本,我们转移到运行捆绑包exec unicorn_rails...在我们的bluepill文件里。这个更改解决了这个特定的问题,事情开始和停止,但当我们尝试sudo bluepill状态时,我们现在得到
独角兽(pix: XXXXXX):无监控
看起来bluepill现在没有监控独角兽进程。如果我停止子进程,它将重新启动它们,但不会重新启动父进程。
我到处寻找,但找不到太多关于这个问题的信息,希望有人能给我一些启发。bluepill配置文件是
app_dir = "/opt/local/share/httpd/apps/xyz"
Bluepill.application('xyz', :log_file => "#{app_dir}/current/log/bluepill.log") do |app|
app.process('unicorn') do |process|
process.pid_file = "#{app_dir}/shared/pids/unicorn.pid"
process.working_dir = "#{app_dir}/current"
process.stdout = process.stderr = "#{app_dir}/shared/log/unicorn.err.log"
process.start_command = "bundle exec unicorn_rails -D -c #{app_dir}/current/config/environments/production/unicorn.rb -E production"
process.stop_command = "kill -QUIT {{PID}}"
process.restart_command = "kill -USR2 {{PID}}"
process.start_grace_time = 8.seconds
process.stop_grace_time = 5.seconds
process.restart_grace_time = 13.seconds
process.monitor_children do |child_process|
child_process.stop_command = "kill -QUIT {{PID}}"
child_process.checks :mem_usage, :every => 10.seconds, :below => 200.megabytes, :times => [3,5]
child_process.checks :cpu_usage, :every => 10.seconds, :below => 50, :times => [3,5]
end
end
end发布于 2011-08-18 23:42:35
当您运行bundle exec时,它会设置一个环境并派生unicorn_rails进程。Bluepill最终监视原始的bundle exec进程,而不是独角兽进程,这就是为什么您看到无监视的原因。
我直接在bluepill中设置我的bundler环境,然后直接执行unicorn_rails:
Bluepill.application('xyz') do |app|
app.environment = `env -i BUNDLE_GEMFILE=#{app_dir}/Gemfile bundle exec env`.lines.inject({}) do |env_hash,l|
kv = l.chomp.split('=',2)
env_hash[kv[0] = kv[1]
env_hash
end
app.process('unicorn') do |process|
process.start_command = "unicorn_rails -D -c #{app_dir}/current/config/environments/production/unicorn.rb -E production"
end
end(注意:为了清楚起见,我省略了上述配置文件的一部分。您的配置文件看起来不错,只需尝试添加上面的app.environment内容并从启动命令中删除bundle exec即可。)
这将在bluepill中设置环境,方法是使用反标记捕获bundler环境变量,将返回的字符串解析为散列并将其分配给app.environment。
发布于 2011-09-16 19:35:28
我知道这个问题很老了,但是我已经面对这个问题好几个星期了。我的怀疑是当我意识到“bluepill退出”,然后在独角兽运行时重新加载该药片时,允许bluepill认为该过程“向上”。
@blt04的回答没有帮助。今天我终于明白了。我8秒的宽限启动时间是不够的,因为我的独角兽配置中有preload_app true……我的应用程序(Rails)加载需要12秒,而不是8秒。
将开始时间提高到30秒(大大超过了所需的时间)解决了问题。Bluepill只会说“开始”30秒,然后正确地转到“向上”。独角兽正常启动和运行。
你也会希望你的重启时间比Rails的启动时间更长。
https://stackoverflow.com/questions/6221888
复制相似问题