Как контролировать процесс Sidekiq, запущенный systemd? - PullRequest
0 голосов
/ 22 апреля 2020

Как я могу отслеживать процесс sidekiq, запускаемый systemd в Ubuntu?

В частности, как выглядит файл monit? (Я нигде не вижу pid-файл для sidekiq)

версии:

ubuntu 18.04.4
sidekiq 6.0.6
monit 5.27.0

sidekiq.service:

[Unit]
Description=sidekiq

After=syslog.target network.target

[Service]

Type=notify
WatchdogSec=10

WorkingDirectory=/var/www/develop/my_app/current

ExecStart=/usr/local/rvm/bin/rvm-exec 2.5.3 bundle exec sidekiq -e develop
ExecReload=/usr/bin/kill -TSTP $MAINPID

# !!! Change this to your deploy user account !!!
User=www-data
Group=www-data
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

# https://www.freedesktop.org/software/systemd/man/systemd.exec.html#StandardOutput=
StandardOutput=file:/var/www/develop/my_app/shared/log/sidekiq.log
StandardError=file:/var/www/develop/my_app/shared/log/sidekiq.log

# This will default to "bundler" if we don't specify it
SyslogIdentifier=sidekiq

[Install]
WantedBy=multi-user.target

/ etc / monit /velop / my_app / myapp_develop_sidekiq:

check process myapp_develop_sidekiq ??? <- what comes here?
    start program = "/bin/systemctl start sidekiq" as uid root
    stop program  = "/bin/systemctl stop sidekiq" as uid root

    if cpu > 80% for 5 cycles then restart
    if totalmem > 16 GB for 15 cycles then restart
    if 3 restarts within 5 cycles then timeout

    group all_develop

1 Ответ

1 голос
/ 23 апреля 2020

Может быть, вы хотите что-то вроде:

ExecStartPost=echo $MAINPID > /var/run/sidekiq.pid
ExecStopPost=rm /var/run/sidekiq.pid
...