前言:在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 框架中的进程的更多相关文章

  1. 在laravel框架中使用mq

    本文写于2018-11-28 1.部署laravel项目 https://github.com/laravel/laravel  通过git克隆项目,或者下载zip包然后解压等方式都可以把larave ...

  2. laravel框架中所用到的依赖注入

    用Laravel开发前前后后有2个月左右了,之前一直写Java,就像找到Java和PHP之前的共同点,用Java的某些原理去理解PHP会发现还是有很多共通之处的.Java的依赖注入已经是一个很常见的概 ...

  3. Laravel框架中的数据库CURD操作、连贯操作、链式操作的用法

    Laravel是一套简洁.优雅的PHP Web开发框架(PHP Web Framework).它可以让你从面条一样杂乱的代码中解脱出来:它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁.富于 ...

  4. laravel框架中Job和事件event的解析

    本篇文章给大家带来的内容是关于laravel框架中Job和事件event的解析,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 在做项目的时候,一直对Job和Event有个疑惑.感觉两 ...

  5. laravel框架中超实用的功能介绍

    本篇文章给大家带来的内容是关于laravel框架中超实用的功能介绍,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. 让lumen的dd() dump()像laravel一样优雅 1 c ...

  6. Laravel框架中Echo的使用过程

    今天的这篇文章中给大家分享关于laravel框架中echo的使用,文章的内容是一步一步来的,用了16步走完一个过程,过程很清晰,希望可以帮助到有需要的朋友吧.话不多说,直接看内容.官方文档推荐使用 P ...

  7. laravel框架中使用QueryList插件采集数据

    laravel框架中使用queryList 采集数据 采集数据对我们来说真家常便饭,那么苦苦的写正则采集那么一点点东西,花费了自己大把的时间和精力而且没有一点技术含量,这个时候就是使用我们的好搭档Qu ...

  8. Laravel框架中实现supervisor执行异步进程

    问题描述:在使用Laravel框架实现动态网页时,若有些操作计算量较大,为了不影响用户体验,往往需要使用异步方式去处理.这里使用supervisor和laravel自带的queues实现. Super ...

  9. 关于Laravel框架中Guard的底层实现

    1. 什么是Guard 在Laravel/Lumen框架中,用户的登录/注册的认证基本都已经封装好了,开箱即用.而登录/注册认证的核心就是: 用户的注册信息存入数据库(登记) 从数据库中读取数据和用户 ...

  10. 使用supervisor管理tomcat,nginx等进程详解

    1,介绍 官网:http://supervisord.org Supervisor是用Python开发的一套通用的进程管理程序,能将一个普通的命令行进程变为后台daemon,并监控进程状态,异常退出时 ...

随机推荐

  1. VIT论文笔记

    VIT An image is worth 16x16 words: transformers for image recognition at scale 将transformer首次应用在视觉任务 ...

  2. iOS 防止charles抓包

    方案一:检查手机Wifi是否设置了代理     public func fetchHttpProxy() -> Bool {        guard let proxy = CFNetwork ...

  3. golang运算符

    1.算术运算符 算术运算符有:+,-,*,/,%,++,-- 1.1 加号(+) 表示正数 数字相加 字符串拼接 package main import ( "fmt" ) fun ...

  4. SpringBoot 自定义启动的logo(即banner)

    1.自定义输出banner样式 推荐生成网站 http://patorjk.com/software/taag/ https://www.bootschool.net/ascii-art 2.配置 A ...

  5. 教你如何自己搭环境部署华为FusionCompute虚拟化系统

    https://www.bilibili.com/video/BV1iy4y177f4?p=10 实用的干货快先码起来,说不定以后会用到哟

  6. Nextcloud报 PHP zip 模块未安装

    wget https://pecl.php.net/get/zip自动下载最新包 tar xf zip-1.20.0.tgz cd zip-1.20.0/ phpize 报错system libzip ...

  7. flink sql任务出现java.lang.OutOfMemoryError: Metaspace

    线上任务一直出现以下错误导致一直重启,然后一直因为这个错误挂掉 org.apache.flink.shaded.guava18.com.google.common.util.concurrent.Ex ...

  8. 「SOL」Quick Tortoise (Codeforces)

    只能说没想到 题面 给出一个 \(n\times m\) 的网格图,每个格子要么是空地要么是障碍. 给出 \(q\) 个询问,每次给出 \((sx, sy),(ex,ey)\),问从 \((sx,sy ...

  9. python菜鸟学习: 12. 装饰器的中级用法

    # -*- coding: utf-8 -*-username = "liyuzhoupan"password = "123"def author(wrappr ...

  10. Microsoft Project 使用教程

    Microsoft Project使用教程 一.新建项目 1. Project界面操作 "文件" -→ "新建" -→ "空白项目" 建议在 ...