使用supervisor 管理 laravel 框架中的进程
前言:在laravel中,经常要在项目根目录下执行 php artisan queue:work 来执行队列中的任务,由此,我们想到用supervisor来管理这个进程
Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时能自动重启。它是通过fork/exec的方式把这些被管理的进程当作supervisor的子进程来启动,这样只要在supervisor的配置文件中,把要管理的进程的可执行文件的路径写进去即可。也实现当子进程挂掉的时候,父进程可以准确获取子进程挂掉的信息的,可以选择是否自己启动和报警。supervisor还提供了一个功能,可以为supervisord或者每个子进程,设置一个非root的user,这个user就可以管理它对应的进程。
安装 supervisor
ubuntu系统下的安装,直接使用命令
$ apt-get install supervisor
修改配置
安装完了之后开始修改配置文件
$ /etc/supervisor/supervisord.conf
修改例子如下
访问账号 user /123 通过浏览器9001端口管理这些进程同时创建 local-cookhome-queue-worker进程
; supervisor config file [unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
chown=vagrant ;用户
[inet_http_server]
port=0.0.0.0:9001 ;http 访问端口
username=user ;http 账户
password=123 ;http 密码 [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) ; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[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 ; The [include] section can just contain the "files" setting. This
; setting can list multiple files (separated by whitespace or
; newlines). It can also contain wildcards. The filenames are
; interpreted as relative to this file. Included files *cannot*
; include files themselves.
[program:local-cookhome-queue-worker] ;管理进程名
user=root ;运行账户
command=php artisan queue:work ;具体命令
directory=/home/vagrant/code/cookhome.local ;目录
[include]
files = /etc/supervisor/conf.d/*.conf
supervisor 常用命令
#重启
$ service supervisor restart #启动
$ service supervisor start #停止
$ service supervisor stop
#查看所有子进程的状态:
$ supervisorctl status
通过浏览器管理进程
使用supervisor 管理 laravel 框架中的进程的更多相关文章
- 在laravel框架中使用mq
本文写于2018-11-28 1.部署laravel项目 https://github.com/laravel/laravel 通过git克隆项目,或者下载zip包然后解压等方式都可以把larave ...
- laravel框架中所用到的依赖注入
用Laravel开发前前后后有2个月左右了,之前一直写Java,就像找到Java和PHP之前的共同点,用Java的某些原理去理解PHP会发现还是有很多共通之处的.Java的依赖注入已经是一个很常见的概 ...
- Laravel框架中的数据库CURD操作、连贯操作、链式操作的用法
Laravel是一套简洁.优雅的PHP Web开发框架(PHP Web Framework).它可以让你从面条一样杂乱的代码中解脱出来:它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁.富于 ...
- laravel框架中Job和事件event的解析
本篇文章给大家带来的内容是关于laravel框架中Job和事件event的解析,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 在做项目的时候,一直对Job和Event有个疑惑.感觉两 ...
- laravel框架中超实用的功能介绍
本篇文章给大家带来的内容是关于laravel框架中超实用的功能介绍,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 让lumen的dd() dump()像laravel一样优雅 1 c ...
- Laravel框架中Echo的使用过程
今天的这篇文章中给大家分享关于laravel框架中echo的使用,文章的内容是一步一步来的,用了16步走完一个过程,过程很清晰,希望可以帮助到有需要的朋友吧.话不多说,直接看内容.官方文档推荐使用 P ...
- laravel框架中使用QueryList插件采集数据
laravel框架中使用queryList 采集数据 采集数据对我们来说真家常便饭,那么苦苦的写正则采集那么一点点东西,花费了自己大把的时间和精力而且没有一点技术含量,这个时候就是使用我们的好搭档Qu ...
- Laravel框架中实现supervisor执行异步进程
问题描述:在使用Laravel框架实现动态网页时,若有些操作计算量较大,为了不影响用户体验,往往需要使用异步方式去处理.这里使用supervisor和laravel自带的queues实现. Super ...
- 关于Laravel框架中Guard的底层实现
1. 什么是Guard 在Laravel/Lumen框架中,用户的登录/注册的认证基本都已经封装好了,开箱即用.而登录/注册认证的核心就是: 用户的注册信息存入数据库(登记) 从数据库中读取数据和用户 ...
- 使用supervisor管理tomcat,nginx等进程详解
1,介绍 官网:http://supervisord.org Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时 ...
随机推荐
- K8s集群版本升级
k8s组件升级流程: 升级主管理节点→升级其他管理节点→升级工作节点 首先备份主管理节点的etcd,检查版本号,为了保证版本的兼容性,跨度最好不要超过两个版本. [root@master ~]# ku ...
- iOS开发 调试技巧
1.普通断点 2.条件断点 3.全局断点 4.analyze 分析器 5.leaks 检查器 6.僵尸对象 7.lldb 命令 8.instruments 9.xcode视图调试
- 记一次SpringBoot整合WebSocket 找不到ServerEndpointExporter类的问题
package com.mengxiangnongfu.cms.framework.configure; import org.springframework.context.annotation.B ...
- 软件测试肖sir__多线程、多进程、多协程
Python并发编程有三种方式: 1.多线程Thread(threading)(读音:思来d,丁).多进程Process(multiprocessing).多协程Coroutine(asyncio) ...
- [iOS]获取地理位置信息
1.在工程的 info.plist 文件中增加两个key( 右键 - Add Row ) Privacy - Location Always and When In Use Usage Descrip ...
- 【GROMACS】分子动力学模拟①——环境搭建
系统环境 Win11 22H2 企业版 开启虚拟化.window subsystem for liunx等虚拟机相关的功能 应用商店中安装WSL2 安装步骤 打开Ubuntu,输入sudo apt f ...
- app打包尺寸
APP上架图标要求 a. app图标: ios: 1024x1024 png 尺寸要小 png 安卓:72x72 96x96 144x144 192x192 b. app启动图: iOS 启 ...
- gitlab 安装以及汉化
转载 https://www.bbsmax.com/A/pRdBAg465n/
- Nginx教程由浅入深
Nginx 一.安装Nginx 1.准备工作 (1)打开虚拟机,使用远程连接工具连接 linux 操作系统 (2)到 nginx 官网下载软件 http://nginx.org/ 2.开始进行 n ...
- Vue3学习笔记(1)
安装 //使用yarn构建 //安装yarn 需要管理员权限 sudo npm i yarn -g yarn create vite cd .. yarn yarn dev 目录结构 见名知义 四种语 ...
