閱讀393 返回首頁    go 技術社區[雲棲]


使用systemd管理Yii2(或其他)隊列服務,實現故障重啟、開機自啟動等功能

以Centos7為例

/usr/lib/systemd/system 目錄新建 queue.service 文件

[Unit]
Description=Yii Queue Server
After=network.target
After=syslog.target
[Service]
Type=forking
PIDFile=/var/run/www-yii-queue.pid
ExecStart=/home/www/yii queue/listen --verbose=1 --color=0 >> /var/logs/www-yii-queue.log 2>&1
ExecStop=/bin/kill $MAINPID
ExecReload=/bin/kill -USR1 $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target graphical.target

接著設置

systemctl daemon-reload
systemctl enable queue.service
systemctl start queue.service

搞定。該隊列服務就開機自啟,其他軟件腳本也可以使用類似手法來實現服務化。

最後更新:2017-09-14 14:02:29

  上一篇:go  手把手 | 30行JavaScript代碼,教你分分鍾創建神經網絡
  下一篇:go  利用JSON-schema校驗請求報文,封裝轉換錯誤信息,提示前台