偶尔,每当我在收到以下错误后不久将发布推到Heroku (我运行的是2 512‘m dynos):
2014-11-21 00:38:30.216
188 <45>1 2014-11-21T00:38:29.163459+00:00 heroku web.2 - - Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
我使用的是独角兽应用服务器,不幸的是,每512 my的dyno只有一个独角兽工人(因为在它的峰值,我的应用RSS是320 my是的,去计算,一些膨胀正在发生)。不确定这是否有帮助,但我在Cedar14上启用了预引导。UNICORN_WORKERS
设置为1。
这是我的独角兽装置。我应该关注这个错误吗?
当我们讨论这个主题时,对于我的2个dynos来说,db池大小15太大了(我正在使用Postgres标准,它允许最多120个并发连接)。
worker_processes Integer(ENV['UNICORN_WORKERS'] || 2)
timeout Integer(ENV['UNICORN_TIMEOUT'] || 25)
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
if defined?(ActiveRecord::Base)
ActiveRecord::Base.connection.disconnect!
end
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
# other settings
if defined?(ActiveRecord::Base)
config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env]
config['reaping_frequency'] = Integer(ENV['DB_REAPING_FREQUENCY'] || 10)
config['pool'] = ENV['DB_POOL'] || 15
ActiveRecord::Base.establish_connection(config)
end
end
发布于 2014-11-21 18:52:25
Heroku在部署时有一条规则,基本上是这样的:
这样做是为了确保您不会有一个庞大的账单运行,因为您的一个进程从来没有退出。
在您的情况下(我在这里推测),您有很多开放的DB连接,关闭它们需要超过10秒,因为:
总的来说,这没什么大不了的。这个问题随着时间的推移会自行解决,所以我不会担心它。
https://stackoverflow.com/questions/27052990
复制相似问题