SidekiqConfiguration » History » Version 4
Mischa The Evil, 2020-06-14 07:58
Fix typo (obsolete suffixed at sign).
| 1 | 3 | Go MAEDA | h2. Sidekiq configuration |
|---|---|---|---|
| 2 | 1 | Marius BĂLTEANU | |
| 3 | 3 | Go MAEDA | "Sidekiq":https://sidekiq.org/ is one of the more widely used background job frameworks that you can configure as queuing backend. I've tested to following install and configuration steps on a fresh Ubuntu 18.04 with Redmine 4.1.1, Redis version 4 and Sidekiq 6. |
| 4 | 1 | Marius BĂLTEANU | |
| 5 | h3. 1. Prerequisites: |
||
| 6 | |||
| 7 | # Install redis-server. |
||
| 8 | |||
| 9 | 3 | Go MAEDA | h3. 2. Install sidekiq |
| 10 | 1 | Marius BĂLTEANU | |
| 11 | # Add the gem as dependency in @Gemfile.local@ file. If the file doesn't exist, you need to create it. |
||
| 12 | <pre> |
||
| 13 | gem 'sidekiq' |
||
| 14 | </pre> |
||
| 15 | # Run @bundle install@ to install the dependency |
||
| 16 | |||
| 17 | h3. 3. Configure Sidekiq |
||
| 18 | |||
| 19 | 3 | Go MAEDA | # Create @config/sidekiq.yml@ file inside Redmine directory and set the queues |
| 20 | 1 | Marius BĂLTEANU | <pre> |
| 21 | --- |
||
| 22 | :queues: |
||
| 23 | - mailers |
||
| 24 | </pre> |
||
| 25 | |||
| 26 | h3. 4. Configure Redmine to use @sidekiq@ as backend |
||
| 27 | |||
| 28 | # Create @config/additional_environment.rb@ file if the file does not exist by copying the existing example file: |
||
| 29 | <pre> |
||
| 30 | 4 | Mischa The Evil | cp config/additional_environment.rb.example config/additional_environment.rb |
| 31 | 1 | Marius BĂLTEANU | </pre> |
| 32 | # Add the below config line to the file: |
||
| 33 | <pre> |
||
| 34 | config.active_job.queue_adapter = :sidekiq |
||
| 35 | </pre> |
||
| 36 | # Restart Redmine to reload the configuration file. |
||
| 37 | |||
| 38 | h3. 5. Test the configuration |
||
| 39 | |||
| 40 | # Browse to Information tab from Redmine Administration page and check the mailer queue value: |
||
| 41 | <pre> |
||
| 42 | Mailer queue ActiveJob::QueueAdapters::SidekiqAdapter |
||
| 43 | </pre> |
||
| 44 | # Perform some actions in Redmine in order to trigger some notifications emails. In this step, Redmine only pushes the background jobs to Sidekiq backend. |
||
| 45 | # Temporary start sidekiq in order to process the queue and send the emails: |
||
| 46 | <pre> |
||
| 47 | RAILS_ENV=production bundle exec sidekiq |
||
| 48 | </pre> |
||
| 49 | |||
| 50 | Output example of startup process: |
||
| 51 | <pre> |
||
| 52 | 2020-06-13T15:08:12.470Z pid=23782 tid=gqluhczs2 INFO: Booted Rails 5.2.4.2 application in production environment |
||
| 53 | 2020-06-13T15:08:12.470Z pid=23782 tid=gqluhczs2 INFO: Running in ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu] |
||
| 54 | 2020-06-13T15:08:12.470Z pid=23782 tid=gqluhczs2 INFO: See LICENSE and the LGPL-3.0 for licensing details. |
||
| 55 | 2020-06-13T15:08:12.470Z pid=23782 tid=gqluhczs2 INFO: Upgrade to Sidekiq Pro for more features and support: https://sidekiq.org |
||
| 56 | 2020-06-13T15:08:12.471Z pid=23782 tid=gqluhczs2 INFO: Booting Sidekiq 6.0.7 with redis options {} |
||
| 57 | </pre> |
||
| 58 | |||
| 59 | Output example of job processing: |
||
| 60 | <pre> |
||
| 61 | 2020-06-13T14:53:19.773Z pid=23268 tid=gmo48ykw4 class=ActionMailer::DeliveryJob jid=0b1943f5a675330944781492 INFO: start |
||
| 62 | 2020-06-13T14:53:21.171Z pid=23268 tid=gmo48ykw4 class=ActionMailer::DeliveryJob jid=0b1943f5a675330944781492 elapsed=1.397 INFO: done |
||
| 63 | </pre> |
||
| 64 | 2 | Marius BĂLTEANU | # If everything went well, stop the command. |
| 65 | 1 | Marius BĂLTEANU | |
| 66 | h3. 6. Configure sidekiq to run as a system service |
||
| 67 | |||
| 68 | # Follow the official steps described in https://github.com/mperham/sidekiq/wiki/Deployment#running-your-own-process |
||
| 69 | # The above steps points to a @sidekiq.service@ example file which can be used to configure the service |
||
| 70 | # During service configuration, at least the following information must be provided: |
||
| 71 | |||
| 72 | * @WorkingDirectory@ |
||
| 73 | * @User@ |
||
| 74 | * @Group@ |
||
| 75 | |||
| 76 | I recommend to carefully read all the instructions and how to configure the service. |
||
| 77 | # Enable and start the service: |
||
| 78 | <pre> |
||
| 79 | sudo systemctl enable sidekiq |
||
| 80 | sudo systemctl start sidekiq |
||
| 81 | </pre> |
||
| 82 | # Test again the email notifications |