Supervisor 安裝除錯記錄

adong發表於2021-07-05
  • yum install Supervisor
  • 修改 vim /etc/supervisor.conf
      files = ./supervisor.d/*.conf
  • /etc/supervisor.d/ 目錄下面安裝自己要啟動的程式 可以建立很多個
    eg:laravl-horizon.conf
          [program:laravel-horizon]
          process_name=%(program_name)s_%(process_num)02d
          command=php /www/wwwroot/fox/artisan horizon   
          autostart=true
          autorestart=true
          user=zhangdd
          numprocs=4
          redirect_stderr=true
          stdout_logfile=/www/wwwroot/fox/storage/logs/horizon.log
          stopwaitsecs=1200
  • 啟動下面命令
    sudo supervisorctl reread
    sudo supervisorctl update
    sudo supervisorctl start laravel-horzion:*

*這裡面有個啟動時候報錯[ 解決辦法]
使用supervisor守護frpc客戶端程式,確保開機自啟埠,記錄報錯過程。
下面是轉載怕人家部落格刪除了www.cnblogs.com/liusingbon/p/12716...
報錯1:[centos@localhost supervisor]$ sudo supervisord

/usr/lib/python2.7/site-packages/supervisor/options.py:461: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a “-c” argument specifying an absolute path to a configuration file for improved security.

‘Supervisord is running as root and it is searching ‘

解決:按照上面的提示,用supervisord 直接啟動supervisor 會引起報錯,故第一次啟動的時候要加上配置檔案。

[centos@localhost supervisor]$ sudo supervisord -c /etc/supervisord.conf

報錯2:[centos@localhost supervisor]$ sudo supervisord -c /etc/supervisord.conf

Unlinking stale socket /var/run/supervisor/supervisor.sock

解決:

[centos@localhost supervisor]$ unlink /var/run/supervisor/supervisor.sock

報錯3:[centos@localhost supervisord.d]$ sudo supervisorctl status

unix:///var/run/supervisor/supervisor.sock no such file

解決:

1.需改許可權

sudo chmod 777 /run
sudo chmod 777 /var/log

2.建立supervisor.sock檔案

[centos@localhost supervisord.d]$ sudo touch /var/run/supervisor/supervisor.sock

[centos@localhost supervisord.d]$ sudo chmod 777 /var/run/supervisor/supervisor.sock

3.重啟

[centos@localhost supervisor]$ sudo supervisord -c /etc/supervisord.conf

報錯4:[centos@localhost supervisor]$ sudo supervisord -c /etc/supervisord.conf

Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.

For help, use /bin/supervisord -h

解決:

[centos@localhost supervisor]$ ps -ef | grep supervisord #檢視supervisord程式

root 13000 1 0 16:59 ? 00:00:00 /usr/bin/python /bin/supervisord

centos 13347 3471 0 17:00 pts/0 00:00:00 grep –color=auto supervisord

[centos@localhost supervisor]$ sudo kill -s SIGTERM 13000 #殺死程式

[centos@localhost supervisor]$ ps -ef | grep supervisord #確認程式supervisord被殺死

centos 13664 3471 0 17:01 pts/0 00:00:00 grep –color=auto supervisord

[centos@localhost supervisor]$ sudo supervisord -c /etc/supervisord.conf #啟動新的supervisord程式

記得設定開機自啟:systemctl enable supervisord

驗證:systemctl is-enabled supervisord

本作品採用《CC 協議》,轉載必須註明作者和本文連結
寫程式碼是一件趣事。

相關文章