简体   繁体   English

如何在不加载整个rails环境的情况下将Job排入ActiveJob?

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

I'd like to enqueue a Job to ActiveJob from different places. 我想从不同的地方把一份工作安排到ActiveJob。 Sometimes from command line, sometimes from a cron job. 有时来自命令行,有时来自cron作业。 But loading the whole environment every time, just to create an entry in redis doesn't feel very efficient. 但是每次加载整个环境,只是为了在redis中创建一个条目并不是非常有效。

Is there an other solution to quickly add a job to ActiveJob without loading the whole Rails-Application. 是否有其他解决方案可以快速向ActiveJob添加作业而无需加载整个Rails-Application。

I know, this should be a job for spring, but (I don't know why) it still takes around 5 seconds: 我知道,这应该是春天的工作,但(我不知道为什么)它仍然需要大约5秒钟:

> 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. 哦,如果这很重要:我使用sidekiq。

ActiveJob needs Rails; ActiveJob需要Rails; you cannot use ActiveJob without booting Rails. 你不能在没有启动Rails的情况下使用ActiveJob。

You can create Sidekiq native Worker jobs without booting Rails. 您可以在不启动Rails的情况下创建Sidekiq本机Worker作业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM