当前位置: 首页 > 知识库问答 >
问题:

在centos 7上安装并配置supervisord以永久运行Laravel队列

安泰平
2023-03-14

我想在我的项目中使用Laravel队列系统,我想运行php artisan队列:在服务器的后台永久工作,我对此进行了一些搜索,找到了一个命令行,即使从ssh终端退出后也可以运行它,但在某些情况下它可能会停止运行,并可能给我带来严重的问题。所以过了一段时间,我发现有一个名为Supervisord的包,它可以在服务器重新启动后重新启动命令。因此,我想请某人逐步帮助从0到100如何在centos 7上安装和配置Supervisord,然后设置队列命令行。非常感谢你。。

共有3个答案

程峻
2023-03-14

在我的Bluehost帐户上,系统ctl没有运行,而是使用chkserv来监控和重启进程,所以这里的两个答案对我来说并不完全有效。

此外,我还遇到了一个错误,easy\u install supervisor,因为它试图安装新的4。x、 x版本,需要Python

以下是对我有效的方法:

>

easy_install监管者

nano/etc/supervisord。conf并添加

[supervisord]
nodaemon=true

[include]
files = /etc/supervisor/conf.d/*.conf

[program:laravel-worker]
command=php artisan queue:work --tries=1
autostart=true
autorestart=true
stderr_logfile=/var/log/queue.err.log
stdout_logfile=/var/log/queue.out.log

nano/etc/chkserv。d/chkservd。conf,添加行supervisord:1,然后保存文件

touch/etc/chkserv。d/supervisord创建chkservd配置文件

nano/etc/chkserv。d/supervisords,添加行service[supervisords]=x,x,x,service supervisords restart,supervisords,root,然后保存文件

supervisord现在将显示在WHM中的Service Manager下,chkservd将启动它并确保它保持运行,但要手动启动它,只需运行supervisord

有关向chkservd添加服务的详细信息,请单击此处。

丁业
2023-03-14

希望这对某人有用,除了@Abdu的回答之外,这也是我在CentOS 7上工作的过程。

1.安装主管

easy_install主管

*如果没有安装,运行yum安装-y python-setupols,然后easy_install主管

2.准备工作

要运行理想的安装程序,您应该运行以下操作...

# create directory for supervisor logs
mkdir /var/log/supervisor

# create directory for supervisor configs
mkdir -p /etc/supervisor/conf.d

# create config directory for supervisor
cat <<EOT >> /etc/supervisor/supervisord.conf
; supervisor config file

[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

[include]
files = /etc/supervisor/conf.d/*.conf
EOT

# create systemctl service script
cat <<EOT >> /lib/systemd/system/supervisord.service
[Unit]
Description=Supervisor process control system for UNIX
Documentation=http://supervisord.org
After=network.target

[Service]
ExecStart=/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
ExecReload=/usr/bin/supervisorctl -c /etc/supervisor/supervisord.conf $OPTIONS reload
KillMode=process
Restart=on-failure
RestartSec=50s

[Install]
WantedBy=multi-user.target
EOT

完成此操作后,您现在应该能够使用system ctl启动和停止主管。若要启动System ctl,请运行System ctl start监督员。若要查看监督者的状态,请运行system ctl的状态监督者

您可以在/etc/supervisor/conf.d

3.在系统启动时启用

您还应该在启动时通过运行

systemctl enable supervisord
薛英卫
2023-03-14

以下是如何在centos 7上安装和配置supervisord以永久运行Laravel队列:

  1. easy_install主管
  2. yum安装主管
  3. vim /etc/supervisord.conf编辑部分程序如下:
[program:laravel-worker]
command=php /path/to/app.com/artisan queue:work 
process_name=%(program_name)s_%(process_num)02d
numprocs=8 
priority=999 
autostart=true
autorestart=true  
startsecs=1
startretries=3
user=apache
redirect_stderr=true
stdout_logfile=/path/to/log/worker.log
 类似资料:
  • 我有一个奇怪的问题Laravel队列:工作。在我的crontab中,我设置了一个工作,就像Laravel文档中描述的那样 在我的应用程序/控制台/Kernel.php我设置这个: 在我的正式服php工匠队列中:工作运行几秒钟,然后被“杀死”。这就是我所期望的。 在我的开发盒php artisan队列中:工作永远运行。因此,激活cron作业会产生php进程,直到整个内存被填满。 两个盒子都是Cent

  • 本文向大家介绍Centos7上Mesos和Marathon的安装和配置,包括了Centos7上Mesos和Marathon的安装和配置的使用技巧和注意事项,需要的朋友参考一下 对Mesos和Marathon的安装官方文档有较详细的安装说明,但是英文的。我参照官方安装文档(https://open.mesosphere.com/getting-started/install/),在测试环境试装了一下

  • 本文向大家介绍centos7 mysql数据库安装和配置,包括了centos7 mysql数据库安装和配置的使用技巧和注意事项,需要的朋友参考一下 一、系统环境 yum update升级以后的系统版本为 二、mysql安装 一般网上给出的资料都是 安装mysql和mysql-devel都成功,但是安装mysql-server失败,如下:  查资料发现是CentOS 7 版本将MySQL数据库软件从

  • 本文向大家介绍CentOS7下 Apache的安装配置方法,包括了CentOS7下 Apache的安装配置方法的使用技巧和注意事项,需要的朋友参考一下 前些天安装了Nginx,为了好玩我就又安装Apache,Apache的安装还算顺利。在此做一下学习记录和经验分享。 一、安装httpd   1、先查看一下系统有没有已经安装了httpd的,如果啥都没查到,那就是没安装呗。如果有#rpm -e 查到的

  • 本文向大家介绍CentOS7中配置Docker的yum源并安装使用详解,包括了CentOS7中配置Docker的yum源并安装使用详解的使用技巧和注意事项,需要的朋友参考一下 此处使用的是CentOS7,内核版本为 该版本下,配置了yum的源为阿里的镜像源,具体的配置方法可以参见阿里镜像源配置方法 为了方便的安装升级Docker,同时按照Docker官方文档中的方式,配置Docker的yum源,具

  • Kibana4 安装方式依然简单,你可以在几分钟内安装好 Kibana 然后开始探索你的 Elasticsearch 索引。只需要预备: Elasticsearch 1.4.4 或者更新的版本 一个现代浏览器 - 支持的浏览器列表. 有关你的 Elasticsearch 集群的信息: 你想要连接 Elasticsearch 实例的 URL 你想搜索哪些 Elasticsearch 索引 如果你的