How to make Sidekiq workers not load Rails environment

The My Rails app launches a Sidekiq worker that only sends text messages. I'm pretty sure there is no need to work for Rails to work (only client phone and text are required to send as parameters). But the worker is currently loading it and thus grabbing most of the memory from my tiny DigitalOcean blob (like a standalone Rails application, for example).

Is it possible to specify the worker path to the only file that should be required?

+3


source to share


2 answers


You can completely decouple your sidekiq worker from autonomy (one or two files) and run it as a separate process on your digital ocean instance. Then in your rails app, when you're ready to go, you simply push the job to redis:

Sidekiq::Client.push({
    'class' => TextMessageWorker,
    'queue' => queue_name,
    'args'  => [number, message]
})

      



There are obvious limitations to this (no scheduling AFAIK), but it should satisfy your needs for this small example.

+3


source


You can use -r

to request a file rather than download Rails.



+2


source







All Articles