Итак, мне трудно понять, почему Sidekiq ведет себя так. Я использую следующий sidekiq.service для включения Sidekiq при запуске (с здесь ):
#
# systemd unit file for CentOS 7+, Ubuntu 15.04+
#
# Customize this file based on your bundler location, app directory, etc.
# Put this in /usr/lib/systemd/system (CentOS) or /lib/systemd/system (Ubuntu).
# Run:
# - systemctl enable sidekiq
# - systemctl {start,stop,restart,reload} sidekiq
#
# This file corresponds to a single Sidekiq process. Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
#
[Unit]
Description=sidekiq
# start us only once the network and logging subsystems are available,
# consider adding redis-server.service if Redis is local and systemd-managed.
After=syslog.target network.target
# See these pages for lots of options:
#
# https://www.freedesktop.org/software/systemd/man/systemd.service.html
# https://www.freedesktop.org/software/systemd/man/systemd.exec.html
#
# THOSE PAGES ARE CRITICAL FOR ANY LINUX DEVOPS WORK; read them multiple
# times! systemd is a critical tool for all developers to know and understand.
#
[Service]
Type=simple
WorkingDirectory=/opt/myapp/current
# If you use rbenv:
# ExecStart=/bin/bash -lc '/home/deploy/.rbenv/shims/bundle exec sidekiq -e production'
# If you use the system's ruby:
ExecStart=/usr/local/bin/bundle exec sidekiq -e production
# use `systemctl reload sidekiq` to send the quiet signal to Sidekiq
# at the start of your deploy process.
ExecReload=/usr/bin/kill -TSTP $MAINPID
User=deploy
Group=deploy
UMask=0002
# 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=multi-user.target
Все выглядит хорошо. Сервис активен и включен без ошибок. Однако, через некоторое время, кажется, go чтобы заснуть? Соблюдайте следующие команды:
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 7994 1 99 13:38 ? 00:00:02 /var/deploy/application/web_head/shared/bundle/ruby/2.5.0/bin/sidekiq
deploy+ 8006 1643 0 13:39 pts/0 00:00:00 grep --color=auto sidekiq
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 8372 1643 0 13:40 pts/0 00:00:00 grep --color=auto sidekiq
deploy-user@bach-fa39e9:/etc/systemd/system$ sudo systemctl status sidekiq
● sidekiq.service - sidekiq
Loaded: loaded (/etc/systemd/system/sidekiq.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-01-08 13:40:47 CET; 3s ago
Main PID: 8434 (bundle)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/sidekiq.service
└─8434 /var/deploy/application/web_head/shared/bundle/ruby/2.5.0/bin/sidekiq
Jan 08 13:40:47 bach-fa39e9 systemd[1]: Started sidekiq.
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 8495 1 74 13:41 ? 00:00:00 /var/deploy/application/web_head/shared/bundle/ruby/2.5.0/bin/sidekiq
deploy+ 8507 1643 0 13:41 pts/0 00:00:00 grep --color=auto sidekiq
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 8864 1 97 13:42 ? 00:00:04 /var/deploy/application/web_head/shared/bundle/ruby/2.5.0/bin/sidekiq
deploy+ 8878 1643 0 13:42 pts/0 00:00:00 grep --color=auto sidekiq
После просмотра состояния с помощью systemctl, Sidekiq волшебным образом оживает. Этого не должно быть, потому что я бы хотел, чтобы Sidekiq слушал все время. Еще один пример, когда Sidekiq приходит в себя после того, как подскакивает за ним (вы даже можете увидеть, что Sidekiq оживает после второй команды):
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 18516 1643 0 14:20 pts/0 00:00:00 grep --color=auto sidekiq
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 18541 1 0 14:20 ? 00:00:00 /usr/local/bin/ruby /usr/local/bin/bundle exec sidekiq
deploy+ 18556 1643 0 14:20 pts/0 00:00:00 grep --color=auto sidekiq
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 18541 1 86 14:20 ? 00:00:02 /var/deploy/application/web_head/shared/bundle/ruby/2.5.0/bin/sidekiq
deploy+ 18558 1643 0 14:20 pts/0 00:00:00 grep --color=auto sidekiq
deploy-user@bach-fa39e9:/etc/systemd/system$ ps -ef | grep sidekiq
deploy+ 18576 1 89 14:20 ? 00:00:02 /var/deploy/application/web_head/shared/bundle/ruby/2.5.0/bin/sidekiq
deploy+ 18588 1643 0 14:20 pts/0 00:00:00 grep --color=auto sidekiq
Я действительно не понимаю, почему это происходит или почему Sidekiq даже 'спит ». Я на Ubuntu 18.04.2 LTS.