Last active
March 3, 2017 13:35
-
-
Save rpocklin/308ba709a9647f7d1b92 to your computer and use it in GitHub Desktop.
How to set rufus scheduler affinity to first worker thread in puma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## in config/puma.rb | |
on_worker_boot do |worker_number| | |
# only create scheduler on first worker thread | |
if worker_number === 0 | |
$scheduler_thread = true | |
end | |
end | |
## in config/initializers/scheduler.rb | |
if $scheduler_thread | |
Rails.logger.info "Created rufus scheduler" | |
scheduler = Rufus::Scheduler.new | |
## add scheduler stuff | |
end | |
## will only ever get 1 Rails.logger.info message :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this working? I do not get any logger messages.