最近在使用frp內網穿透,以便自己的工具能在外網訪問。自己內網主機有時需要重啟,為了工具能正常訪問,所以使用supervisor工具進行進程管理,supervisor的自啟動成個很必要的需求。下面簡單描述下我從stackoverflow上找到的解決方案,並配上我自己的配置。
1.在/lib/systemd/system/中添加supervisord.service文件
配置如下:
[Unit] Description=Supervisord Service [Service] Restart=on-failure RestartSec=42s User=myuser ExecStart=/home/myuser/.pyenv/versions/3.6.8/bin/supervisord -n -c /home/myuser/etc/supervisord.conf [Install]
User替換成你的用戶名,ExecStart 命令中supervisord的路徑替換成你自己的路徑 supervisord.conf同樣替換成你自己的配置路徑,常用路徑是/etc/supervisord.conf,因權限問題我在用戶目錄里添加了配置。
2. 執行如下命令
sudo systemctl daemon-reload
sudo systemctl enable supervisord.service
sudo systemctl start supervisord.service
最后重啟就可以看到,supervisor已經自啟動
3.說明
本方法適用ubuntu16.04及以上版本
參考: