Ubuntu 安装和使用 Supervisor(进程管理)
服务器版本 Ubuntu 16.04 LTS。
Supervisor 是一个用 Python 写的进程管理工具,可以很方便的对进程进行启动、停止、重启等操作。
安装命令:
$ apt-get install supervisor
安装成功后,会在/etc/supervisor
目录下,生成supervisord.conf
配置文件。
你也可以使用echo_supervisord_conf > supervisord.conf
命令,生成默认的配置文件(不建议,内容比较多)。
supervisord.conf
示例配置:
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[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.
[include]
files = /etc/supervisor/conf.d/*.conf
进程配置会读取/etc/supervisor/conf.d
目录下的*.conf
配置文件,我们在此目录下创建一个hwapp.conf
进程配置文件:
[program:hwapp]
directory=/root/wwwroot/hwapp/publish
command=dotnet hwapp.dll
autostart=true
autorestart=true
startretries=10
redirect_stderr=true
stdout_logfile=/root/wwwroot/hwapp/hwapp.log
environment=ASPNETCORE_ENVIRONMENT="Development"
需要注意的是,如果不是root
账号,需要对这些目录进行权限设置,要不然会报一些错误(一定要在 root 账号下进行配置,要不然一系列权限引起的问题😂)。
$ sudo chmod 777 /var/run
$ sudo chmod 777 /etc/supervisor
接着就可以启动 Supervisord 了:
$ supervisord
supervisorctl
常用命令:
命令 | 说明 |
---|---|
supervisorctl stop program_name | 停止某个进程 |
supervisorctl start program_name | 启动某个进程 |
supervisorctl restart program_name | 重启某个进程 |
supervisorctl stop all | 停止全部进程 |
supervisorctl reload | 载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程 |
supervisorctl update | 根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启 |
参考资料:
作者:田园里的蟋蟀
微信公众号:你好架构
出处:http://www.cnblogs.com/xishuai/
公众号会不定时的分享有关架构的方方面面,包含并不局限于:Microservices(微服务)、Service Mesh(服务网格)、DDD/TDD、Spring Cloud、Dubbo、Service Fabric、Linkerd、Envoy、Istio、Conduit、Kubernetes、Docker、MacOS/Linux、Java、.NET Core/ASP.NET Core、Redis、RabbitMQ、MongoDB、GitLab、CI/CD(持续集成/持续部署)、DevOps等等。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
微信公众号:你好架构
出处:http://www.cnblogs.com/xishuai/
公众号会不定时的分享有关架构的方方面面,包含并不局限于:Microservices(微服务)、Service Mesh(服务网格)、DDD/TDD、Spring Cloud、Dubbo、Service Fabric、Linkerd、Envoy、Istio、Conduit、Kubernetes、Docker、MacOS/Linux、Java、.NET Core/ASP.NET Core、Redis、RabbitMQ、MongoDB、GitLab、CI/CD(持续集成/持续部署)、DevOps等等。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
分类:
[21]Mac OS/Linux
标签:
[31]小菜学习编程-Linux
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2016-08-31 jQuery.Ajax IE8 无效(CORS)
2015-08-31 读书记录(持续更新...)