How to enqueue a Job to ActiveJob without loading the whole rails environment?

651 views Asked by At

I'd like to enqueue a Job to ActiveJob from different places. Sometimes from command line, sometimes from a cron job. But loading the whole environment every time, just to create an entry in redis doesn't feel very efficient.

Is there an other solution to quickly add a job to ActiveJob without loading the whole Rails-Application.

I know, this should be a job for spring, but (I don't know why) it still takes around 5 seconds:

> time rails runner -e production 'SynchronizeStuffJob.perform_later'
[ActiveJob] Enqueued SynchronizeStuffJob (Job ID: 148e34bd-c38c-45c9-86f5-5a959a548ebb) to Sidekiq(default)

real    0m5.122s
user    0m4.385s
sys     0m0.663s

Oh and if this matters: I use sidekiq.

1

There are 1 answers

2
Mike Perham On

ActiveJob needs Rails; you cannot use ActiveJob without booting Rails.

You can create Sidekiq native Worker jobs without booting Rails.