惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyberwarzone
Cyberwarzone
Jina AI
Jina AI
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Google DeepMind News
Google DeepMind News
博客园 - 司徒正美
宝玉的分享
宝玉的分享
C
Check Point Blog
有赞技术团队
有赞技术团队
小众软件
小众软件
IT之家
IT之家
Vercel News
Vercel News
V2EX - 技术
V2EX - 技术
雷峰网
雷峰网
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
Engineering at Meta
Engineering at Meta
Schneier on Security
Schneier on Security
P
Privacy International News Feed
Apple Machine Learning Research
Apple Machine Learning Research
W
WeLiveSecurity
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
J
Java Code Geeks
T
Threatpost
S
Secure Thoughts
T
Tailwind CSS Blog
V
V2EX
Attack and Defense Labs
Attack and Defense Labs
P
Palo Alto Networks Blog
S
Security @ Cisco Blogs
The GitHub Blog
The GitHub Blog
Simon Willison's Weblog
Simon Willison's Weblog
The Register - Security
The Register - Security
AWS News Blog
AWS News Blog
罗磊的独立博客
GbyAI
GbyAI
Blog — PlanetScale
Blog — PlanetScale
Microsoft Azure Blog
Microsoft Azure Blog
Forbes - Security
Forbes - Security
N
News | PayPal Newsroom
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
爱范儿
爱范儿

夜行人

回家路上 第一期的直播演示项目 震动检测器 正能量 在线参观CodeLab Neverland 发布 CodeLab Adapter 3.3.1 DynamicTable 之 纸糊方向盘 CodeLab DynamicTable: 一个可实施的技术方案 CodeLab Insight 发布 Alpha 版 情人节 Home Assistant 周报 && IoT 周报 (02) Joplin: 关注隐私的 Evernote 开源替代软件 浏览器的未来与 Web 传感器 Home Assistant 周报 && IoT 周报 (01) 百宝箱(01) 论自由 介绍 WebThings Home Assistant 周报 && iot 周报 (00) 百宝箱(00) 毛姆读书心得 传世之作 周末徒步 CodeLab Adapter ❤️ Jupyter/Python 航班 躲雨 夏令营途中 [译]思想--作为一种技术 The future of coding 美国之行 三门问题的程序模拟 从Python转向Pharo https://blog.just4fun.site/post/iot/iot-open-source-projects/ Python异步编程笔记 https://blog.just4fun.site/post/iot/iot-open-source-hardware-community/ 万物积木化开发者社区 CodeLab ❤️ Blender Scratch3技术分析之云变量 API(第7篇) [译]对管道(Pipes)的偏爱 [译]提出正确的问题比得到正确答案更重要 蓝牙设备与Scratch3.0 创建你的第一个Scratch3.0 Extension Scratch3技术分析之项目内部数据(第6篇) Scratch3技术分析之社区 API(第5篇) Scratch3技术分析之User API(第4篇) Scratch3技术分析之项目主页API(第3篇) Scratch3技术分析之静态资源API(第2篇) Scratch3.0、micro:bit与Windows7 https://blog.just4fun.site/post/iot/zerynth-vs-micropython/ 核聚变、方所与半宅空间 可视化编程为何是个糟糕的主意 codelab.club周末聚会 关于codelab.club '下一件大事'是一个房间 Hungry Robot - Eat everything 编程作为一种思考方式 今日简史 史蒂夫·乔布斯传 罗素自选文集 https://blog.just4fun.site/post/edx/tianjin-scratch-ai/ https://blog.just4fun.site/post/edx/richie-cms-openedx/ 徒步武功山 WebUSB与micro:bit 积木化编程与3D场景 夜宿武功山顶 scratch3-adapter接入优必选Alpha系列机器人 https://blog.just4fun.site/post/edx/video-migration-note/ scratch3-adapter重构笔记 https://blog.just4fun.site/post/edx/edx-community-members/ 两种硬件编程风格的比较 使用micro:bit自制PPT翻页笔 柏拉图对话集 scratch3.0 + micro:bit 七月电影放映计划 非营利组织的管理 Screenly--用树莓派让任何屏幕变为可编程的数字标牌 以最佳实践开始你的Django项目 micro:bit与事件驱动 为Scratch3.0设计的插件系统(上篇) OCR应用一例 近两年读过的一些好书 blockly开发之使用python驱动浏览器中的turtle(2) 牛顿新传 文学理论入门 逻辑的引擎 人生的意义 blockly开发之生成并运行js代码(1) blockly开发之hello world(0) micro:bit使用笔记 神器之Termux https://blog.just4fun.site/post/iot/micropython-notes/ Cozmo what is this Scratch的前世今生 下段旅程 我行在远方 爆裂 途中杂记 https://blog.just4fun.site/post/edx/open-edx-startup/ cozmo系列之入门 - 有性格且可编程的机器人 PaperWeekly开发笔记 创业二三事
使用Supervisor来管理进程
2015-09-06 · via 夜行人

#Supervisor是什么

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.

Supervisor是用Python实现的一款实用的进程管理工具。Supervisor会帮你把管理的应用程序转成daemon程序,而且可以方便的通过命令开启、关闭、重启进程等操作,而且它管理的进程一旦崩溃会自动重启,这样就可以保证程序执行中断后的情况下有自我修复的功能。

#安装与配置 Supervisor本质上是个python包,安装很简易:sudo pip install supervisor

##配置文件 运行echo_supervisord_conf,会输出一个模板,修修改改就可用了。 将其写入文件:sudo echo_supervisord_conf > supervisord.conf
如果没有root权限,可以将配置文件写在本地,之后用-c参数来指定配置文件: supervisord -c supervisord.conf。推荐做法是将配置文件写到/etc/supervisord.conf

###生成默认配置文件(推荐做法)

1
2
echo_supervisord_conf > /etc/supervisord.conf
mkdir /etc/supervisord.conf.d

每个需要管理的进程分别写在一个文件里面,放在/etc/supervisord.conf.d/目录下,便于管理。修改配置文件,include区段修改为

1
2
3
:::text
[include]
files = /etc/supervisord.conf.d/*.conf

如需要访问web控制界面,inet_http_server区段修改为

1
2
3
4
5
:::text
[inet_http_server]
port=0.0.0.0:9001
username=username 
password=password 

修改后需要supervisorctl reload (载入最新的配置文件,并按新的配置启动、管理所有进程。)

开机自启

将supervisord加入系统服务,文件:/etc/init.d/supervisord

简单的方法是往/etc/rc.local加入/usr/local/bin/supervisord

##使用

  • Supervisord安装完成后有两个可用的命令行supervisorsupervisorctl
  • supervisord:初始启动Supervisord,启动、管理配置中设置的进程: 启动supervisord:supervisord -c /etc/supervisord.conf
  • supervisorctl stop programxxx,停止某一个进程(programxxx),programxxx为[program:programxxx]里配置的值。stop可替换为start/restart/reload

##edX中(Cypress版本) ####Shutdown the lms and cms:

1
2
3
:::text
sudo /edx/bin/supervisorctl  
> stop edxapp: edxapp_worker:

####See what services are running sudo /edx/bin/supervisorctl status

####Restarting Services LMS/CMS : sudo /edx/bin/supervisorctl restart edxapp:
Workers : sudo /edx/bin/supervisorctl restart edxapp_worker:

####stop everything except the LMS and CMS sudo /edx/bin/supervisorctl stop discern discern_celery forum ora ora_celery xqueue xqueue_consumer xserver edxapp_worker:

###edx中相关配置文件 搜索sudo find / -name *supervisord*。观察发现lms和cms相关的配置文件在/edx/app/supervisor/supervisord.conf , /edx/app/supervisor/conf.d/*.conf

其中lms的配置文件为

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
:::text
[program:lms]

command=/edx/app/edxapp/venvs/edxapp/bin/gunicorn -c /edx/app/edxapp/lms_gunicorn.py lms.wsgi

user=www-data
directory=/edx/app/edxapp/edx-platform
environment=PORT=8000,ADDRESS=127.0.0.1,LANG=en_US.UTF-8,DJANGO_SETTINGS_MODULE=lms.envs.aws,SERVICE_VARIANT="lms",PATH="/edx/app/edxapp/venvs/edxapp/bin:/edx/app/edxapp/edx-plat
form/bin:/edx/app/edxapp/.rbenv/bin:/edx/app/edxapp/.rbenv/shims:/edx/app/edxapp/.gem/bin:/edx/app/edxapp/edx-platform/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
stdout_logfile=/edx/var/log/supervisor/%(program_name)s-stdout.log
stderr_logfile=/edx/var/log/supervisor/%(program_name)s-stderr.log
killasgroup=true
stopasgroup=true

##参考资料

文章作者 种瓜

上次更新 2015-09-06