Ubuntu 如何监控systemd运行的sidekiq进程?

Ubuntu 如何监控systemd运行的sidekiq进程?,ubuntu,sidekiq,systemd,monit,Ubuntu,Sidekiq,Systemd,Monit,版本: ubuntu 18.04.4 sidekiq 6.0.6 monit 5.27.0 如何使用monit监视systemd运行的sidekiq进程 具体来说,monit文件是什么样子的?(我在任何地方都没有看到sidekiq的pidfile) sidekiq.service: [Unit] Description=sidekiq After=syslog.target network.target [Service] Type=notify WatchdogSec=10 Work

版本:

ubuntu 18.04.4
sidekiq 6.0.6
monit 5.27.0
如何使用monit监视systemd运行的sidekiq进程

具体来说,monit文件是什么样子的?(我在任何地方都没有看到sidekiq的pidfile)

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/develop/my_app/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
检查流程myapp\u develop\u sidekiq???80%持续5个循环,然后重新启动
如果totalmem>16 GB并持续15个周期,则重新启动
如果3次在5个周期内重新启动,则超时
集体发展

也许您想要的是:

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

也许你想要这样的东西:

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

谢谢你,我必须按照你的建议创建一个pidfile来让它工作
ExecStartPost=/bin/sh-c'/bin/echo$MAINPID>/var/run/sidekiq.pid'
谢谢,我按照您的建议创建了一个pid文件,让它工作起来了
ExecStartPost=/bin/sh-c'/bin/echo$MAINPID>/var/run/sidekiq.pid'