Development environment : running sidekiq and discourse at startup

My development environment is a dedicated Ubuntu server (my project involves two web apps interacting with each other, too heavy and too complicated to set up locally). On this server, I would like to run sidekiq and discourse at startup. I played with rc.local, but couldn’t figure it out. Anyone succeeded with this?

Why can’t you run Discourse in a docker container, as recommended?

Because I develop plugins.

Sidekiq creator just tweeted about this:

https://twitter.com/mperham/status/837024296044130304

If Discourse is auto starting in this setup you created, just add a new line there to start sidekiq. If you are on latest Ubuntu that would be a systemd service file.

Not sure why you need an auto starting Sidekiq in a dev instance tough. That’s where I enjoy having a tighter control about stuff like sidekiq.

1 Like

Thanks a lot @Falco. My Discourse doesn’t auto start, that is my problem. And systemd looks very complicated to set up…

Only because it is recommended here (at the end): Discourse does a lot of stuff async, so it’s better to run sidekiq even on development mode.

There is a screen script that you can run that will start all necessary components

https://github.com/discourse/discourse/blob/master/docs/vagrant.screen

It is setup for the vagrant image but should be easy to amend.

Make a copy of it and change the cd /vagrant to your discourse directory

7 Likes

Amazing, thanks @cpradio!

Notice that I was not able to start sidekiq this way. Or was I? The various sidekiq-related messages are confusing, to say the least, but as sidekiq seems to be optional, I will forget about it for now.

Well, it is and it isn’t, depending on what you’re testing. Sidekiq handles a lot of “jobs” like updating the Users page, etc.

On my localhost when I want sidekiq to be running I usually just open another terminal and start it in that.

1 Like

To find out, you simply need to press CTRL + a, ", it will show you a list, move up to the sidekiq one and press enter.

Here is a screenshot of the list

Here is the sidekiq window

There are a lot of good references out there for using screen, quick_reference [GNU screen] and linux screen keyboard shortcuts, for example.

3 Likes

Thanks @cpradio. I had mistakenly added a -d option, that’s why I had no output in the window. I also had this Discourse message saying that Sidekiq was not running (I have no explanation for this). But the message is gone now and everything looks fine. Thanks again.

1 Like

I am having similar problems running sidekiq in a docker development environment. I have explored other topics with no success. I know sidekiq is running because going to localhost:3000/sidekiq shows me the sidekiq dashboard. I also see that every job stays in the Enqueued section. I have three terminal windows in my development environemt.

  1. Rails server that I started with d/rails s
  2. Mailcatcher that I started with d/mailcatcher
  3. Sidekiq that I started with d/sidekiq

I just cant for the life of me figure out why the admin dashboard says that sidekiq is not running, and why jobs stay in the enqueued section

I always have this warning message and Sidekiq works like a charm. So I came to the conclusion it’s the standard behavior for a dev instance.

This workaround worked for me: change config.eager_load to true in development.rb. See this thread:

2 Likes

Thank you! That fixed it

It seems Sidekiq is now launched automatically when the dev instance starts. Am I right? Still any need to launch it manually?

If you run bin/unicorn it automatically runs sidekiq if you don’t want sidekiq run bin/unicorn -x

4 Likes