gpt4 book ai didi

ruby - 我怎样才能告诉 unicorn 理解 Heroku 的信号?

转载 作者:数据小太阳 更新时间:2023-10-29 06:48:59 26 4
gpt4 key购买 nike

也许你已经看到了这个......

2012-03-07T15:36:25+00:00 heroku[web.1]: Stopping process with SIGTERM2012-03-07T15:36:36+00:00 heroku[web.1]: Stopping process with SIGKILL2012-03-07T15:36:36+00:00 heroku[web.1]: Error R12 (Exit timeout) -> Process failed to exit within 10 seconds of SIGTERM2012-03-07T15:36:38+00:00 heroku[web.1]: Process exited with status 137

这是运行时的一个众所周知的问题 unicornheroku ...

我可以让 heroku 发送 SIGQUIT 吗?或者我可以告诉 unicorn 将 SIGTERM 视为正常关机吗?

最佳答案

Heroku 现在在这里提供了相关说明: https://blog.heroku.com/archives/2013/2/27/unicorn_rails

他们建议的 unicorn.rb 文件是:

# config/unicorn.rb
worker_processes 3
timeout 30
preload_app true

before_fork do |server, worker|

Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end

defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|

Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
end

defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end

关于ruby - 我怎样才能告诉 unicorn 理解 Heroku 的信号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9605703/

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