天天看點

centos 7 設定easyswoole開機自啟動

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