SidekiqConfiguration » History » Version 2

Marius BALTEANU, 2020-06-13 17:27

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