57

Sidekiq has been working in development mode just perfectly. Now that I am trying to use it in production, all the jobs are just sitting in enqueue and aren't ever being run. Could anyone point me in the right direction as to how to solve this issue?

groffcole
  • 871
  • 1
  • 7
  • 18
  • 1
    I assume you are running at least one sidekiq worker on production? – cthulhu Jun 20 '13 at 10:21
  • Yes, I believe so. What exactly do you mean? I did start Sidekiq by running the following command: bundle exec sidekiq -d -L /path/to/log. And there is an asynchronous call to a worker I've created in my Rails code. – groffcole Jun 20 '13 at 15:44
  • 1
    whats in your logs? do you see sidekiq process? (ps aux | grep sidekiq) what's in your sidekiq console? – cthulhu Jun 20 '13 at 16:06
  • 1
    do you put jobs in default queue? – cthulhu Jun 20 '13 at 16:15
  • My log file doesn't show anything Sidekiq is doing. I can see the Sidekiq process: 'groff 18288 0.0 0.0 3396 756 pts/0 S+ 16:24 0:00 grep sidekiq'. I don't have a Sidekiq console because I started it as a daemon. The Sidekiq monitoring pages show 9 jobs in the enqueue. Yes, jobs are in the default queue. I did not setup any other queues. – groffcole Jun 20 '13 at 16:25
  • 1
    It looks like your sidekiq process isn't started at all, if you posted complete output of 'ps aux | grep sidekiq' command. Try starting sidekiq in foreground first, without any additional options, just 'bundle exec sidekiq' – cthulhu Jun 20 '13 at 16:47
  • Here is the output from 'bundle exec sidekiq': `Rails Error: Unable to access log file. Please ensure that /var/www/findalma.com/apps/findalma_gold/findalma_gold/log/development.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed. database configuration does not specify adapter` It looks as though it's trying to start in development mode? I don't understand why it would look for the development.log log and ignore the production database settings. – groffcole Jun 20 '13 at 16:55
  • If it's any help, I'm running this on Ubuntu 10.04 using RVM, Apache, and Passenger. – groffcole Jun 20 '13 at 17:06
  • I think I've figured it out. Jobs are now being processed. I ran this command: `rvmsudo bundle exec sidekiq -e production -d -L log/production.log`. Now when I run ps aux | grep sidekiq I get this: `root 19847 11.7 8.0 173132 83304 ? Sl 17:17 0:27 sidekiq 2.12.4 findalma_gold [0 of 25 busy]`. And, from the monitoring pages I see that there are no longer and jobs enqueue. So it seems my issue was not setting the environment. Now I suppose I should figure out how to properly setup redis and Sidekiq using init files? – groffcole Jun 20 '13 at 17:22
  • I think you shouldn't run sidekiq as 'root'. I forgot to tell you about '-e production' switch. I think it should be ok when you run 'bundle exec sidekiq -e production'. If you are using capistrano, take a look at: https://github.com/mperham/sidekiq/wiki/Deployment. – cthulhu Jun 20 '13 at 18:04
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/32097/discussion-between-cthulhu-and-groffcole) – cthulhu Jun 20 '13 at 18:08

7 Answers7

56

Please check if sidekiq process is actually running:

ps aux | grep sidekiq

If it is not, try to run sidekiq in foreground first and check the output.

bundle exec sidekiq -e production
cthulhu
  • 3,749
  • 1
  • 21
  • 25
  • So simple, yet so correct. In my particular case I had worker file misconfigured and it was killing the sidekiq process – Jay Dorsey Dec 21 '15 at 20:38
20

In many cases for me it's because I haven't properly declared the queue for this specific service in config/sidekiq.yml.

paascal
  • 314
  • 5
  • 8
4

This answer looks relevant: Sidekiq not processing queue If Sidekiq isn't told about the config file (which may require a different incantation in production) then it may not be using the right queue.

Community
  • 1
  • 1
ChrisPhoenix
  • 1,040
  • 1
  • 11
  • 16
3

Just a heads up to all as I ended up this page trying to figure out why my Rails Sidkiq jobs were not moving off 'enqueued'.

  1. Check your sidekiq console in your terminal
  2. My issue which messed me up for almost an hour... duh... I had a 'byebug' breakpoint in the code that is silly to put in a background job. This will totally foul your job up. Obviously... I didn't mean to put that breakpoint there. I swear :)
slindsey3000
  • 4,053
  • 5
  • 36
  • 56
2

My solution:

1.) Look at the Sidekiq Web UI for your app (this is where you can see the fact that jobs are getting into an enqueued state).

2.) Manually retry a failed job

3.) Inspect logs on the server running Sidekiq:

(generally this is where the log will be located, if say you are doing this on staging)

tail -f /var/www/yourappname/current/log/staging.log

This is generally where you will see a more detailed error message of why Sidekiq cannot process enqueued jobs. In our case, there was an environment variable pointing to an incorrect endpoint specific to our deployment configuration.

Joseph Combs
  • 909
  • 9
  • 12
1

Make sure your app sidekiq process run

$ ps aux | grep sidekiq
server   26813  0.0  0.0  14228  1084 pts/11   S+   11:27   0:00 grep --color=auto sidekiq
server   27936  0.3  0.6 1178904 153240 ?      Sl   Apr17  46:02 sidekiq 5.2.7 app1 [0 of 10 busy]

The example show that there is only one sidekiq process running (app1). If your app not in the list, then you have to start sidekiq process for your app, in this example app2 . gem capistrano-sidekiq make your life easier:

$ cap production sidekiq:start
00:00 sidekiq:start
      01 $HOME/.rbenv/bin/rbenv exec bundle exec sidekiq --index 0 --pidfile /var/www/app2/shared/tmp/pids/sidekiq-0.pid --environment produ…
    ✔ 01 server@103.n.nnn.nnn 0.400s

and the app2 process will be activated. Now, check again

$ ps aux | grep sidekiq
server   25857  8.6  7.6 3073532 1870244 ?     Sl   11:15   1:02 sidekiq 5.2.8 app2 [0 of 10 busy]
server   26813  0.0  0.0  14228  1084 pts/11   S+   11:27   0:00 grep --color=auto sidekiq
server   27936  0.3  0.6 1178904 153240 ?      Sl   Apr17  46:02 sidekiq 5.2.7 app1 [0 of 10 busy]

the queue should have been running normally

yohanes
  • 2,365
  • 1
  • 15
  • 24
0

Using capistrano-sidekiq gem solved our problem

Shimaa Marzouk
  • 429
  • 4
  • 10