vim /usr/lib/systemd/system/easy.service
添加以下内容:
[Unit]
Description=The EasySwoole Process Manager
After=syslog.target network.target
[Service]
User=root
Group=root
Type=forking
ExecStart=/usr/bin/php /mnt/share/xxx/easyswoole start d
ExecReload=/usr/bin/php /mnt/share/xxx/easyswoole reload
ExecStop=/usr/bin/php /mnt/share/xxx/easyswoole stop
[Install]
WantedBy=multi-user.target
尝试启动:
systemctl daemon-reload
systemctl start easy
结果报错,查看错误信息:
journalctl -xe
结果发现是autoload.php文件路径不对,查看源代码:
D:\WWW\xxx\easyswoole
改一下EASYSWOOLE_ROOT的定义,这个定义不是很规范,应该使用绝对路径。
defined('EASYSWOOLE_ROOT') or define('EASYSWOOLE_ROOT', IN_PHAR ? \Phar::running() : __DIR__);
再次尝试启动:
systemctl start easy
正常启动!
重启和reload也能正常使用。good!
systemctl restart easy
systemctl stop easy
设置开机自启动:
systemctl enable easy
重启之后查看easy_swoole状态: