Rails 3 Sidekiq Passenger - ruby-on-rails

I am able to get Sidekiq scheduler working locally. The last obstacle in my way is how to deploy this to a production app on passenger. Can someone point me in the right direction on how to run Sidekiq continuously on passenger.
Appreciate it.

Passenger is a Apache\nginx module for running Rails\Rack apps.
Sidekiq is a threaded background worker queue that usually is run with JRuby in production.
You do not run Sidekiq through Passenger.
Rather, just configure Passenger to run and serve you app as needed. Then you can start Sidekiq and have it poll Redis for work. It is highly recommend you use either JRuby or Rubinius so you take full advantage of Sidekiq's threaded nature.
For more details on deploying Sidekiq, refer to the wiki:
https://github.com/mperham/sidekiq/wiki/Deployment
For more details on configuring Passenger refer to it's docs (for either Apache or nginx):
https://www.phusionpassenger.com/support#documentation
Update: From the creator of Sidekiq there is a library called Girl Friday. This library adds an asynchronous job queue but runs inline with your Rails application (or other Rack app). This option can greatly simplify deployment and save money!

Related

How to create worker instances for a Ruby on Rails application using delayed_job or sidekiq with the aws-rails-provisioner gem?

A standard rails app will have web servers for the front end and workers servers for background jobs. Aws-rails-provisioner is a fantastic tool, but does it support the generation of the background workers stack? I could not find out how to define it using the aws-rails-provisioner.yml file.

Sidekiq VS RabbitMQ

We are in need of a queuing system in our Ruby On Rails 4 web application
what are the differences and why would/wouldn't you pick
Sidekiq over RabbitMQ?
It's quite different things with different usage. Sidekiq is full-featured solution for job queueing and processing, while RabbitMQ is just a message broker where you can build your own stuff upon it.

Which schedulers for rails 3.1 or above can stay on all the time on ubuntu 12.04?

We are looking for a scheduler which can stay on all the time for our rails 3.1 app on ubuntu 12.04 server. Currently we are using rufus scheduler which could be killed by Passenger by accident and can not stay on all the time. There are quite a few of schedulers available out there. We are looking for a simple and easy to use one for our rails app. The primary purpose of the scheduler is to fire off periodically to check the session timestamp and reset if necessary. Any recommendation? Thanks.
Have you looked at clockwork?
https://rubygems.org/gems/clockwork
For rufus-scheduler vs Passenger, you might want to look at Debugging Rufus scheduler
Else if you don't want to tune your Passenger, go the crond way and use Whenever: https://github.com/javan/whenever

Any background process gems that work with JRuby deployed on Windows?

Does anyone know a working background job solution for JRuby deployed on a windows server? (via warbler and tomcat)
I'm looking for a way to schedule background jobs from my Rails 3.2 app, so that the web app can respond immediately rather than hang up while a long running job runs.
I tried the delayed_job gem, except it doesn't seem to work with JRuby and Windows. (If I'm wrong, please enlighten me) Resque depends on redis which evidently doesn't support Windows. I don't have experience with Beanstalkd or Starling, but the documentation for them doesn't mention windows.
I'ld love to dump windows, believe me, but the background job is a windows executable that did not come with source. And I need to use JRuby to be able to call some Java code too.
Solved the problem using the jruby-rack-worker gem, http://github.com/kares/jruby-rack-worker, which let's you use delayed_job to schedule jobs, just provides a different way to kickoff worker processes that is more JRuby/Warbler/Tomcat friendly.
We use Rufus Scheduler for that purpose. The scheduler configuration sits in an initializer file like so:
scheduler = Rufus::Scheduler.start_new
scheduler.every('1d') do
puts "I run once every day"
end
scheduler.every '3h' do
puts "I run every 3 hours"
end

How to make/monitor/deploy daemon processes in JRuby

I'm currently porting a Rails App currently using REE to JRuby so I can offer an easy-to-install JRuby alternative.
I've bundled the app into a WAR file using Bundler which I'm currently deploying to GlassFish. However, this app has a couple of daemon processes and it would be ideal if these could be part of the WAR file, and potentially monitored by Glassfish (if possible).
I've looked at QuartzScheduler, and while meets my needs for a couple of things, I have a daemon process that must execute every 20 seconds as it's polling the database for any delayed mail to send.
If anyone can provide any insight as to how best to set up daemon processes in a JRuby/Java/Glassfish environment any help will be greatly appreciated! :)
One way to daemonize a JRuby process is to use akuma framework (on *nix) or others.
I would rather use cronjobs (schedulling) rather than daemons as they are less error-proned, daemons can leak memory, can stop on errors etc. Check jruby-quartz and quartz_scheduler
EDIT
If one uses Torquebox it offers support for services and scheduling.

Resources