Ubuntu中通过SuperVisor添加守护进程

1. 用途

守护进程用于保持一个指定程序(dll)时刻保持运行。在命令行终端中通过dotnet run命令执行的程序,在退出命令行终端后,程序自动终止。添加守护进程后,即使终端退出,程序仍可后台执行。可用于执行定时任务。

2. 安装(环境:ubuntu 16.04 dotnet 2.1.104)

sudo apt-get install supervisor  (必须在root下执行)

3. 修改配置文件

配置文件路径:/ect/supervisor/conf.d/supervisord.conf

直接修改该文件

gedit supervisord.conf

增加:

1)开启查看进程的界面

[inet_http_server]
port=127.0.0.1:7002

2)添加被守护的程序

[program:TimeTest]
command=dotnet TimeTest.dll   ;要执行的指令
directory=/mnt/hgfs/Projects/Linux/SurfaceRunoff/TimeTest/TimeTest/bin/Debug/netcoreapp2.0/publish        ;dll的路径
autostart=true
autorestart=true
numprocs=1
process_name=TimeTests        ;名称

3)重启

supervisord reload

4)访问localhost:7002(与配置文件中的端口相同)即可查看当前正在运行的所有程序

配置文件完整示例:

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)_

[inet_http_server]
port=127.0.0.1:7002

[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:TimeTest]
command=dotnet TimeTest.dll
directory=/mnt/hgfs/Projects/Linux/SurfaceRunoff/TimeTest/TimeTest/bin/Debug/netcoreapp2.0/publish
autostart=true
autorestart=true
numprocs=1
process_name=TimeTests

[include]
files = /etc/supervisor/conf.d/*.conf

4. 参考:

https://www.cnblogs.com/savorboard/p/dotnetcore-supervisor.html(给出的配置文件设置方法似乎有问题,添加后无法通过浏览器进行查看,也可能是版本问题,未再深究)

https://www.cnblogs.com/dingsblog/p/7040680.html(后来按这篇帖子完成配置文件修改)

原文地址:https://www.cnblogs.com/countryer/p/8799106.html

时间: 2024-08-02 21:17:39

Ubuntu中通过SuperVisor添加守护进程的相关文章

[Linux] PHP程序员玩转Linux系列-使用supervisor实现守护进程

1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转Linux系列-备份还原MySQL 5.PHP程序员玩转Linux系列-自动备份与SVN 6.PHP程序员玩转Linux系列-Linux和Windows安装nginx 7.PHP程序员玩转Linux系列-nginx初学者引导 8.PHP程序员玩转Linux系列-Nginx中的HTTPS 首先遇到的问题

Keepalived 之 为nginx添加守护进程

一.在Keepalived 模式下为nginx服务添加守护进程 作用:在Keepalived 模式下(没有LVS情冲况下),缺少程序状态健康检查,如主机-负载均衡的VIP存在,而主机上的NGINX服务意外停止,但此时服务依然会中断,VIP还不会漂移到备机上,为了解决这种情况,我们可以在主机与备机上添加nginx的守护进程来解决此问题. 二.网络拓扑图 原文地址:http://blog.51cto.com/12965094/2158059

Linux中的两种守护进程stand alone和xinetd

--http://www.cnblogs.com/itech/archive/2010/12/27/1914846.html#top 一般使用stand alone /etc/init.d/ 非常少用xinetd /etc/xinetd.d/ Linux守护进程的运行方式 1.独立运行(stand-alone)的守护进程 独立运行的守护进程由init脚本负责管理,所有独立运行的守护进程的脚本在/etc/rc.d/init.d/目录下.系统服务都是独立运行的守护进程,包括syslogd和cron等

Ubuntu中为Eclipse添加桌面启动快捷方式

Ubuntu中应用程序启动器“XXX.desktop”还没有被标记为可信任的问题:http://www.tuicool.com/articles/fIBJ32n eclipse问题:prefences工具栏切换无反应,需要修改eclipse.init配置文件,在最上面加上--launcher.GTK_version2--launcher.library即可 eclipse配置桌面图标启动:sudo touch eclipse.desktop(如果想把eclipse配置在启动栏,则在/usr/sh

ubuntu中为Pycharm添加快捷启动方式

1. sudo gedit /usr/share/applications/Pycharm.desktop 2.在文件中添加: [Desktop Entry] Type=Application Name=Pycharm GenericName=Pycharm5 Comment=Pycharm5:The Python IDE Exec="/home/hupeng/pycharm/bin/pycharm.sh" %f #pycham路径 Icon=/home/hupeng/pycharm/

ansible+Jenkins+supervisor(Jenkins守护进程)

安装的插件 ansible ,ansible+windows ,SDK,gradle 3.0,groovy,svn,git,ant,maven,java-1.8.0-openjdk 本博客所有的脚本都是基于centos7 及windows server 2008 R2 编写 所有的自动化部署工具都是基于 ansible #!/bin/bash if [ $( rpm -qi epel-release | wc -l ) -gt 1 ]; then echo "epel-release insta

asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二)

原文:asp.net core2.0 部署centos7/linux系统 --守护进程supervisor(二) 续上一篇文章:asp.net core2.0 部署centos7/linux系统 --安装部署(一),遗留的问题而来,对程序添加守护进程,使网站可以持续化的运行起来. ? 1.介绍supervisor ?? ?Supervisor(http://supervisord.org/)是用Python开发的一个client/server服务,是Linux/Unix系统下的一个进程管理工具,

Docker 客户端和守护进程

以上为Docker的C/S架构图,从中摘取出Docker 的客户端与守护进程的关系如下: Docker Host 宿主机: 进行docker操作的虚拟机 Docker daemon 守护进程: 负责各种各样的docker操作的核心程序,比如下载或者运行一个docker容器 Client 客户端: 我们通过Client与Docker daemon进行交互,将docker build.dcoker pull.docker run交与Docker daemon去操作.主要的有以下两种接口: 命令行接口

Yii2.0 安装yii2-queue并在Linux启动守护进程监听消息

一.什么是yii2-queue? Yii2-queue是Yii2.0 PHP框架下一个消息队列拓展插件,支持基于DB, Redis, RabbitMQ, AMQP, Beanstalk 和 Gearman等.yii2-queue GitHub地址:https://github.com/yiisoft/yii2-queue 二.如何安装yii2-queue? php composer.phar require --prefer-dist yiisoft/yii2-queue 三.Linux sys