I really don't know why but my sidekiq seems to stop working after a while.
However, if I
/sidekiq
ps aux | grep sidekiq
once I do one of the above two things, sidekiq
begin to poll immediatelyMy environment is
I use systemd
and capistrano-sidekiq to control sidekiq, can anyone help me?
# config/sidekiq.yaml
:queues:
- default
- order-jobs
This is the ~/.config/systemd/user/sidekiq.service
I write:
[Unit]
Description=sidekiq
After=syslog.target network.target
[Service]
Type=notify
WatchdogSec=10
WorkingDirectory=/path/to/my/app/current
ExecStart=/home/my_username/.rvm/bin/rvm in /path/to/my/app/current do bundle exec sidekiq -e production
ExecReload=/usr/bin/kill -TSTP $MAINPID
# Greatly reduce Ruby memory fragmentation and heap usage
# https://www.mikeperham.com/2018/04/25/taming-rails-memory-bloat/
Environment=MALLOC_ARENA_MAX=2
# if we crash, restart
RestartSec=1
Restart=on-failure
# output goes to /var/log/syslog
StandardOutput=syslog
StandardError=syslog
# This will default to "bundler" if we don't specify it
SyslogIdentifier=sidekiq
[Install]
WantedBy=default.target
The user services of systemd
turn out that they only live while the user has a login session.
The service will stop once the last session finishes.
So that's why my sidekiq
, which is run by the user service, stops everytime after I logout.
we can simply use loginctl enable-linger username
to create a continuing existing session of the user.