我如何在Ubuntu上以守护进程的形式运行sidekiq?
如果我运行bundle exec sidekiq -D
,我得到了invalid option: -D
,有没有办法在没有其他控制器的情况下运行它,比如上帝,暴发户……?
发布于 2013-03-20 18:28:48
有一个选项来守护sidekiq,只需传递-d
选项
发布于 2020-07-05 17:27:12
对于Sidekiq版本6或更高版本,不支持作为Unix运行程序的守护程序。相反,我们必须将流程作为服务运行。
根据您的bundler位置编写一个脚本,或者您可以修改以下代码片段并将其复制到/usr/lib/systemd/system
(CentOS)或/lib/systemd/system
(Ubuntu)中
[Unit]
Description=sidekiq
After=syslog.target network.target
[Service]
Type=notify
WatchdogSec=10
WorkingDirectory=/home/deploy/apps/project_name
# If you use rbenv:
# ExecStart=/bin/bash -lc 'exec /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
# If you use rvm in production, don't.
#ExecStart=/home/deploy/.rvm/wrappers/ruby-2.6.5/bundle exec sidekiq -e production
# Use `systemctl kill -s TSTP sidekiq` to quiet the Sidekiq process
# !!! Change this to your deploy user account !!!
User=deploy
Environment=MALLOC_ARENA_MAX=2
# if the script crash, restart
RestartSec=1
Restart=on-failure
# output goes to /var/log/syslog (Ubuntu) or /var/log/messages (CentOS)
StandardOutput=syslog
StandardError=syslog
# This will default to "bundler" if we don't specify it
SyslogIdentifier=sidekiq
[Install]
WantedBy=multi-user.target
确保您为ExecStart
提供了正确的捆绑程序路径,以便启动该进程。将其另存为sidekiq.service
并运行systemctl enable sidekiq
。然后,我们可以使用命令systemctl start sidekiq
、systemctl stop sidekiq
和systemctl restart sidekiq
来管理该过程。
我们可以使用journalctl -u sidekiq -rn 100
查看最后100行日志。
https://stackoverflow.com/questions/15520676
复制相似问题