简体   繁体   English

如何在Sidekiq中运行某个工人一段时间?

[英]How to run a worker for certain duration of time in Sidekiq?

I am writing a rails app in which I have a piece of code which is dependent on Time zones. 我正在编写一个Rails应用程序,其中有一段取决于时区的代码。

How can make my Sidekiq worker, work only in day time of a time zone ie for a certain duration of time everyday. 如何使我的Sidekiq工人只能在时区的白天工作,即每天工作一段时间。

The worker should pause at certain point of time (end of day) even when its queue is not empty and resume the next day. 工人应在某个时间点(一天结束)暂停,即使其队列不为空,也应在第二天恢复工作。

I suggest starting a Cron Job, using the whenever gem that stops the Sidekiq workers at a certain time, and starts them again at a certain time. 我建议使用Cever Job来启动Cron作业,该宝石会在特定时间停止Sidekiq工人,并在特定时间再次启动他们。

You can stop sidekiq workers via sidekiqctl: sidekiqctl stop [pidfile] 60 您可以通过sidekiqctl停止sidekiq工作者:sidekiqctl stop [pidfile] 60

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

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