一、golang、beego等环境安装与配置

二、supervisor安装

github项目地址:https://github.com/Supervisor/supervisor

克隆项目:git clone https://github.com/Supervisor/supervisor.git

进入项目:cd supervisor

安装执行:python setup.py install

三、supervisor配置文件

官方文档-配置部分

vi /etc/supervisord.conf

[supervisord]
http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server)
;http_port=127.0.0.1:9001 ; (alternately, ip_address:port specifies AF_INET)
;sockchmod=0700 ; AF_UNIX socketmode (AF_INET ignore, default 0700)
;sockchown=nobody.nogroup ; AF_UNIX socket uid.gid owner (AF_INET ignores)
;umask=022 ; (process file creation umask;default 022)
logfile=/var/log/supervisor/supervisord.log ; (supervisor输出日志,main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (logging level;default info; others: debug,warn)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200) ;nocleanup=true ; (don't clean up tempfiles at start;default false)
;http_username=user ; (default is no username (open system))
;http_password=123 ; (default is no password (open system))
;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP)
;user=chrism ; (default is current user, required if root)
;directory=/tmp ; (default is not to cd during start)
;environment=KEY=value ; (key value pairs to add to environment) [supervisorctl]
serverurl=unix:///var/tmp/supervisor.sock ; use a unix:// URL for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor") [unix_http_server]
file=/var/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0777 ; socket file mode (default 0700)
;chown=root:root ; socket file uid:gid owner
;username=root ; (default is no username (open server))
;password=root ; (default is no password (open server)) [inet_http_server]
port = 127.0.0.1:9001 [rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [program:hello] ;可以在这边配置要管理的程序
directory=/home/www/php/ ;
command=/usr/bin/php test.php ;
process_name=%(program_name)s ;
numprocs=1 ;
autostart=true ;
startsecs=1 ;
autorestart=true ;
startretries=3 ;
user=root ;
redirect_stderr=true ;
stdout_logfile_maxbytes=20MB ;
stdout_logfile_backups=10 ; [include] ;也可以通过include包含进来程序配置文件
files = ./supervisor/conf.d/*.ini ;

vi /etc/supervisor/conf.d/wx-prj.ini

[program:wx-prj]
;directory=/home/www/go/src/wx-prj ;go项目目录
;command=/home/www/go/src/wx-prj/wx-prj ;go项目编译好的可执行文件
directory=/home/www/go/bin ;
command=/home/www/go/bin/wx-prj ;
process_name=%(program_name)s ;
numprocs=1 ;
autostart=true ;
startsecs=1 ;
autorestart=true ;
startretries=3 ;
user=root ;
redirect_stderr=true ;
stdout_logfile=/home/www/go/wx-prj.stdout.log ;打印标准输出日志
stdout_logfile_maxbytes=20MB ;
stdout_logfile_backups=10 ;
stderr_logfile=/home/www/go/wx-prj.stderr.log ;打印标准错误输出日志
stderr_logfile_maxbytes=20MB ;
stderr_logfile_backups=10 ;
log_stdout=true ; if true, log program stdout (default true)
log_stderr=true ; if true, log program stderr (def false)

四、启动supervisor服务

supervisord -c /etc/supervisord.conf
启动服务时可以跟踪日志输出观察
[root@10-23-67-69 go]# tail -f /var/log/supervisor/supervisord.log
2018-10-26 13:36:30,881 INFO Included extra file "/etc/./supervisor/conf.d/wx-prj.ini" during parsing
2018-10-26 13:36:30,902 INFO RPC interface 'supervisor' initialized
2018-10-26 13:36:30,902 CRIT Server 'inet_http_server' running without any HTTP authentication checking
2018-10-26 13:36:31,203 INFO RPC interface 'supervisor' initialized
2018-10-26 13:36:31,203 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2018-10-26 13:36:31,206 INFO daemonizing the supervisord process
2018-10-26 13:36:31,207 INFO supervisord started with pid 17040
2018-10-26 13:36:32,209 INFO spawned: 'hello' with pid 17041
2018-10-26 13:36:32,213 INFO spawned: 'wx-prj' with pid 17042
2018-10-26 13:36:32,219 INFO spawned: 'world' with pid 17043
2018-10-26 13:36:33,279 INFO success: hello entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-10-26 13:36:33,279 INFO success: wx-prj entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2018-10-26 13:36:33,279 INFO success: world entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
也通过命令查看程序状态
[root@10-23-67-69 conf.d]# supervisorctl status
hello RUNNING pid 17041, uptime 0:00:19
world RUNNING pid 17043, uptime 0:00:19
wx-prj RUNNING pid 17042, uptime 0:00:19

五、重载supervisor修改过的配置

supervisorctl reload

六、停止/启动/重启supervisor管理的程序

[root@10-23-67-69 conf.d]# supervisorctl stop wx-prj
wx-prj: stopped
[root@10-23-67-69 conf.d]# supervisorctl start wx-prj
wx-prj: started
[root@10-23-67-69 conf.d]# supervisorctl restart wx-prj
wx-prj: stopped
wx-prj: started
[root@10-23-67-69 conf.d]# supervisorctl stop all
hello: stopped
wx-prj: stopped
world: stopped
[root@10-23-67-69 conf.d]# supervisorctl start all
hello: started
wx-prj: started
world: started

配置supervisor管理beego应用的更多相关文章

  1. supervisor管理进程工具配置

    Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,不支持Windows系统 ...

  2. 使用Supervisor管理Celery进程。

    讲过一篇celery的,但是celery启动后并不是daemon的,在生产环境中这肯定是不可以的,那怎么办呢? 这就需要使用supervisor进行进程管理了,下面详细介绍. 一. superviso ...

  3. Supervisor 管理后台守护进程

    Supervisor 管理后台守护进程 参考原文如下: http://codinn.com/people/brant/notes/110948/ 做了一些注释 +++++++++++引用开始+++++ ...

  4. 如何使用supervisor管理你的应用

    1.前言 Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是UNIX-like系统下的一个进程管理工具,不支持Windo ...

  5. 使用supervisor管理进程

    Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动.重启.关闭进程(不仅仅是 Python 进程).除了对单个进程的 ...

  6. Supervisor管理进程

    Supervisor管理进程 转载 2016年04月14日 18:26:45 标签: supervisord 28344 Supervisor重新加载配置启动新的进程 liaojie 发布于 1年前, ...

  7. Linux配置Supervisor 配置遇到的坑

    在linux中web 应用部署到线上后之后发现退出终端后网站就无法访问了 所以需要用Supervisor来守护进程,它可以保证应用一直处于运行状态,在遇到程序异常.报错等情况,导致 web 应用终止时 ...

  8. Supervisor 管理进程,Cloud Insight 监控进程,完美!

    Supervisor 是由 Python 语言编写.基于 linux 操作系统的一款服务器管理工具,用于监控服务器的运行,发现问题能立即自动预警及自动重启等. Cloud Insight 是一款次世代 ...

  9. 在 OSX 下使用 supervisor 管理服务

    我为什么想用 supervisor 来管理服务呢?因为我在系统管理上属于处女座+任性的气质. OSX 下办公用的是普通用户,我不想在 root 权限下做过多设置污染我的系统. OSX 下的服务管理我感 ...

随机推荐

  1. uva1673(后缀自动机)

    后缀自动机还是只会打板子,已经知道它是个什么东西了,但还是和它的构造联系不起来..先背板子吧. 后缀自动机有一个很好的特性就是可以涵盖所有不重复的子串,我们利用这一点在它上面dp就行了: 代码参考:h ...

  2. hdu 4911 Inversion and poj2299 [树状数组+离散化]

    题目 题意:  给你一串数字,然后给你最多进行k次交换(只能交换相邻的)问交换后的最小逆序对个数是多少. 给你一个序列,每次只能交换相邻的位置,把他交换成一个递增序列所需要的最少步数 等于 整个序列的 ...

  3. Android-Java-抽象类

    定义抽象类,就一定会定义抽象方法,抽象方法没有方法体{},就证明抽象方法 是不运行的,抽象方法 是给子类继承覆盖运行的, 子类继承->抽象类 就必须覆盖抽象方法,否则编译都失败: 水果案例: 定 ...

  4. 如何将已有的本地Git 库推送到远端仓库?

    以Github 为例 step 1. 在Github建立一个空的仓库 Step 2. 建立远端仓库的别名 >$ git remote add origin https://github.com/ ...

  5. NET Core微服务之路:简单谈谈对ELK,Splunk,Exceptionless统一日志收集中心的心得体会

    前言 日志,一直以来都是开发人员和运维人员最关心的问题.开发人员可通过日志记录来协助问题定位,运维人员可通过日志发现系统隐患,故障等定位问题.如果你的系统中没有日志,就像一个断了线的风筝,你永远不知道 ...

  6. C++中const关键字 理解

    const:符号常量  使用符号常量写出的代码更容易维护:指针是边读边移动,而不是边写边移动,许多函数参数是只读不写的. const最常见用途是作为数组的界和switch分情况标号(也可以用枚举符代替 ...

  7. python 使用进程池Pool进行并发编程

    进程池Pool 当需要创建的子进程数量不多时,可以直接利用multiprocessing中的Process动态成生多个进程,但如果是上百甚至上千个目标,手动的去创建进程的工作量巨大,此时就可以用到mu ...

  8. Java学习笔记54(反射详解)

    反射概念: java反射机制是在运行状态中,对于任意一个类,都能知道所有属性和方法 对于任意一个对象都能调用它的任意一个方法和属性,这种动态获取和调用的功能称为java的反射机制 实际作用: 已经完成 ...

  9. 谈谈我们对userAgent的看法,为什么爬虫中需要userAgent?

    首先打开浏览器,按 F12 进入控制台(Console),然后输入:navigator.userAgent,即可看到 UA.例如: 1 2 Mozilla/5.0 (Windows NT 10.0; ...

  10. Spring Cloud Finchley 正式发布,包含 4 个重大更新!

    在 Spring 的官方博客上已经看到 Spring Cloud Finchley 在 06 月 19 日这一天正式发布了,我们在 Maven 中央仓库也看到了最新版的更新. Finchley 正式版 ...