阅读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校验请求报文,封装转换错误信息,提示前台