gpt4 book ai didi

bundler - 使用 bluepill 监控 bundle 执行 unicorn_rails

转载 作者:行者123 更新时间:2023-12-02 17:53:27 28 4
gpt4 key购买 nike

由于 unicorn_rails 提示不同的 gem 版本,我们转而在 bluepill 文件中运行 bundle exec unicorn_rails... 。此更改解决了该特定问题,并且事情开始和停止,但是当我们尝试 sudo bluepill status 时,我们现在得到

unicorn (像素:XXXXXX):不受监控

看起来 bluepill 现在没有监控 unicorn 进程。如果我停止子进程,它将重新启动子进程,但不会重新启动父进程。

我四处搜寻,但找不到太多关于这个问题的信息,希望有人能对此有所了解。 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

最佳答案

当您运行 bundle exec 时,它会设置一个环境并 fork unicorn_rails 进程。 Bluepill 最终监视原始 bundle exec 进程而不是 unicorn,这就是您看到不受监视的原因。

我直接在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来自您的启动命令。)

这通过使用反引号捕获 bundler 环境变量、将返回的字符串解析为散列并将其分配给 app.environment 来设置 bluepill 中的环境。

关于bundler - 使用 bluepill 监控 bundle 执行 unicorn_rails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6221888/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com