I am trying to send an alert every time retry_count of a sidekiq job reaches 5(to warn an engineer to check why the worker is failing) and then continued being retried as usual.
Is there a way to get the retry count for a particular job from inside the job?
I could just use:
sidekiq_retry_in do |count|
(warn engineer here)
10 * (count + 1) # (i.e. 10, 20, 30, 40)
end
and send a message from in there, but I think its a bit of a hack.
Any ideas? googling didn't surface any results.
Once a worker has started processing a job, you cannot stop it externally without shutting down the entire process. There is no safe way to stop a thread.
To run sidekiq, you will need to open a terminal, navigate to your application's directory, and start the sidekiq process, exactly as you would start a web server for the application itself. When the command executes you will see a message that sidekiq has started.
To test your Sidekiq Worker jobs array, run WorkerNameHere.jobs in terminal and see if it contains your job with your jid. If it does, then it was enqueued in Sidekiq to be run as a job.
There is no way to get the retry count from within the job, by design.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With