一,ubuntu安装supervisor
1, 用apt安装
# apt install supervisor
2,安装完成后查看状态:
# systemctl status supervisor.service
● supervisor.service - Supervisor process control system for UNIX
Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-11-08 13:33:01 CST; 4min 32s ago
Docs: http://supervisord.org
Main PID: 43713 (supervisord)
Tasks: 1 (limit: 4582)
Memory: 18.9M
CPU: 381ms
CGroup: /system.slice/supervisor.service
└─43713 /usr/bin/python3 /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
11月 08 13:33:01 lhdpc systemd[1]: Started Supervisor process control system for UNIX.
11月 08 13:33:01 lhdpc supervisord[43713]: 2024-11-08 13:33:01,885 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config >
11月 08 13:33:01 lhdpc supervisord[43713]: 2024-11-08 13:33:01,885 WARN No file matches via include "/etc/supervisor/conf.d/*.conf"
11月 08 13:33:01 lhdpc supervisord[43713]: 2024-11-08 13:33:01,891 INFO RPC interface 'supervisor' initialized
11月 08 13:33:01 lhdpc supervisord[43713]: 2024-11-08 13:33:01,892 CRIT Server 'unix_http_server' running without any HTTP authentication checking
11月 08 13:33:01 lhdpc supervisord[43713]: 2024-11-08 13:33:01,892 INFO supervisord started with pid 43713
已经开始运行了
二,用supervisor管理octane
1,在/etc/supervisor/conf.d目录下编辑octane.conf
内容:
[program:octane]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php artisan octane:start --port=8000 --workers=4 --task-workers=4
directory=/srv/api
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/data/phplog/octane.log
说明:php需要指定完整路径,否则会报找不到文件
添加配置文件后重新启动:
# systemctl restart supervisor.service
查看是否启动成功:
# ss -lntp | grep 8000
LISTEN 0 512 127.0.0.1:8000 0.0.0.0:* users:(("php",pid=44134,fd=7),("php",pid=44133,fd=7),
("php",pid=44132,fd=7),("php",pid=44131,fd=7),("php",pid=44130,fd=7),
("php",pid=44129,fd=7),("php",pid=44128,fd=7),("php",pid=44127,fd=7),
("php",pid=44122,fd=7),("php",pid=44121,fd=7))
已经守护了我们指定的8000端口
三,测试:
可以用curl访问8000:
curl http://127.0.0.1:8000
也可以从浏览器访问,可以看到服务已启动
标签:laravel,11,13,01,supervisor,33,08,octane From: https://www.cnblogs.com/architectforest/p/18534820