Skip to content

Instantly share code, notes, and snippets.

@rpocklin
Last active March 3, 2017 13:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpocklin/308ba709a9647f7d1b92 to your computer and use it in GitHub Desktop.
Save rpocklin/308ba709a9647f7d1b92 to your computer and use it in GitHub Desktop.
How to set rufus scheduler affinity to first worker thread in puma
## 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 :)
@finist
Copy link

finist commented Mar 3, 2017

Is this working? I do not get any logger messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment