我正在使用Thin,Ruby 2.0.0在Heroku上运行Sinatra应用程序。每隔16个小时左右,我会在日志中收到此错误,并且我的rufus-scheduler计划块中的所有内容都会停止运行。
关于出了什么问题的任何想法?
70217056739720 Rufus::Scheduler::EveryJob "5m" {}
70217056739720 70217056739720
70217056739720 ThreadError
70217056739720 can't create Thread (11)
{ 70217056739720 rufus-scheduler intercepted an error:
70217056739720 job:
70217056739720 error:
70217056739720 /app/lib/pusher_benchmarker.rb:26:in `initialize'
70217056739720 /app/lib/services_runner.rb:13:in `new'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:62:in `initialize'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:62:in `connect'
70217056739720 /app/lib/services_runner.rb:9:in `initialize'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/pusher-client-0.4.0/lib/pusher-client/socket.rb:62:in `new'
70217056739720 /app/lib/pusher_benchmarker.rb:34:in `connect'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:288:in `block (2 levels) in start_work_thread'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:285:in `block (3 levels) in start_work_thread'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:288:in `call'
70217056739720 /app/app.rb:46:in `new'
70217056739720 /app/app.rb:46:in `block (2 levels) in <class:BenchmarkAnalysis>'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:224:in `call'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:224:in `do_call'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:248:in `do_trigger'
70217056739720 /app/lib/services_runner.rb:13:in `initialize_services'
} 70217056739720 .
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:274:in `loop'
70217056739720 /app/vendor/bundle/ruby/2.0.0/gems/rufus-scheduler-3.0.6/lib/rufus/scheduler/jobs.rb:274:in `block in start_work_thread'
答案 0 :(得分:1)
因此,如果Heroku限制线程数,我会限制rufus-scheduler中的工作线程。
https://github.com/jmettraux/rufus-scheduler/#max_work_threads
您可以在实例化调度程序时对其进行调整,例如:
scheduler = Rufus::Scheduler.new(:max_work_threads => 7)
默认情况下,max_work_threads为28。