Struggling to get Sidekiq to work with Rails

Hi,

I’m fairly new to Rails and programming and after spending hours wondering why my app.s jobs were not working, I realized I need to actually start Sidekiq (I know, it should have been obvious but well…)

I’m using Jumpstart Rails and Sidekiq is already configured by Jumpstart. If I run “bundle exec Sidekiq”, Sidekiq starts and the jobs get processed as expected.

My issue is that I can’t figure out how to actually get Sidekiq to always run on Render.

Here is what I have tried so far:

1) Adding “bundle exec Sidekiq” in the render-build.sh file.

Didnt’t work but I don’t remember why exactly.

2) Adding “bundle exec sidekiq” as a start command in Render settings.

This is what I put as a start command in Render.

bundle exec puma -C config/puma.rb; bundle exec sidekiq

This executed Puma as usual but seemingly ignored the Sidekiq part.

3) Adding Sidekiq as a separate worker process in Render

Similar to what’s described here

I used the Render Sidekiq example and followed the instructions from Render but I get a message saying the app isn’t health and the following:

Mar 28 05:53:41 PM  ==> Starting service with 'bundle exec sidekiq -C config/sidekiq.yml'
Mar 28 05:53:42 PM  No such file config/sidekiq.yml

I assume the issue is that the Sidekiq background worked process is not linked to my Rails app web service but I’m not sure how to link it.

I put “bundle install” as a build command and “bundle exec sidekiq -C config/sidekiq.yml” as a start command but left everything identical to the Render example repo otherwise.

I, of course, added a REDIS_URL env variable.

So yeah, I’m utterly confused and not sure what to do. I feel like I’m close but can’t figure out what I should be doing.

Help would be highly appreciated :slight_smile:

It sounds like your close - configuring sidekiq with a sidekiq.yml is optional and depends on how you have setup Sidekiq. You can achieve most of the same things with command line arguments. Step 3 is definitely the right path to be on and if you were to adjust your start command to bundle exec sidekiq then you should find it springs into life.

John B

Thanks but that didn’t work unfortunately. It just keeps telling me the service is unhealthy and doesn’t detect the Rails app in the other web service.

It seems like I need to add something to the bundle exec sidekiq start command so it detects my Rails app that’s in a separate web service but I’m not sure how to do this.

I tried the following but it doesn’t work:

bundle exec sidekiq -r ft-web-xdp6/config/sidekiq.yml

I’m assuming I wrote the path in the wrong way. Any idea how I can point the Sidekiq background worker service to the web service?

Thanks

You should have deployed the same code base to both your web service and the background worker that you intend to run sidekiq via. The background service should be connected to the same database and Redis instance as your webservice. You don’t need to anything specific in the sidekiq command, bundle exec sidekiq is more than enough for most cases.

Your Rails app would ‘queue’ the job into Redis and then the background worker running sidekiq will pick the job up from Redis and then process it on sidekiq. Sidekiq should be connected to the same Redis_URL as the service.

John B

Ah that makes sense. I just did that and it’s working now. Thanks! :slight_smile:

Great, glad you got there.

John B

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.