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/TimeTest/bin/Debug/netcoreapp2.0/publish        ;dll的路径
autostart=true
autorestart=true
numprocs=1
process_name=TimeTests        ;名称

3)重启

supervisorctl 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(后来按这篇帖子完成配置文件修改)

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

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

    Linux中的两种守护进程stand alone和xinetd --http://www.cnblogs.com/itech/archive/2010/12/27/1914846.html#top 一 ...

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

    1.PHP程序员玩转Linux系列-怎么安装使用CentOS 2.PHP程序员玩转Linux系列-lnmp环境的搭建 3.PHP程序员玩转Linux系列-搭建FTP代码开发环境 4.PHP程序员玩转L ...

  3. Ubuntu中找到并杀死僵尸进程

    Ubuntu中产生zombie进程让人很懊恼啊.Windows中在任务管理器里直接找到无响应的进程并结束他就行了,但是ubuntu中需要用命令去解决. System information as of ...

  4. CentOS使用Ubuntu的start-stop-daemon来启动守护进程

    在CentOS下使用守护进程启动有/etc/init.d/functions文件下的daemon方法,但如果要使用Ubuntu下的start-stop-daemon方法也可以实现. 安装如下: # 下 ...

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

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

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

    Ubuntu中应用程序启动器“XXX.desktop”还没有被标记为可信任的问题:http://www.tuicool.com/articles/fIBJ32n eclipse问题:prefences ...

  7. .Net Core实战教程(三):使用Supervisor配置守护进程

    安装Supervisor yum install python-setuptools easy_install supervisor 配置Supervisor mkdir /etc/superviso ...

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

    1. sudo gedit /usr/share/applications/Pycharm.desktop 2.在文件中添加: [Desktop Entry] Type=Application Nam ...

  9. 【Linux】- Ubuntu守护进程supervisor

    linux的守护进程类似于windows的服务.linux通过supervisor创建守护进程. 1.安装supervisor sudo apt-get install supervisor 安装成功 ...

随机推荐

  1. XSS学习(一)

    XSS(一) XSS分类 1.反射型XSS 2.持久性XSS 3.DOM型XSS **** 反射型XSS 也称作非持久型,参数型跨站脚本 主要将Payload附加到URL地址参数中 例如: http: ...

  2. django-枚举类型扩展方法

    原文地址:https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_FOO_disp ...

  3. maven 灵活构建

    灵活构建 项目的构建根据不同的情况可能需要有一定的差异,比如编译级别.依赖.打包的属性文件等在不同的运行环境中可能需要有不同的值.为了实现灵活构建,Maven内置了三个特性: 属性:在POM中通过${ ...

  4. DevExpress中GridControl的使用笔记

    主要参考链接:DevExpress GridControl控件使用 Content [Level 1:基本](#Level 1:基本) [Level 2:列名](#Level 2:列名) [Level ...

  5. Java小代码

    1. public class test1 {public static void main(String[] args) { Person P = new Person("gdsgds&q ...

  6. python 数字以及字符串(方法总结,有的可能理解错误)

    数字类型(int): 在python 2中,数字类型可以分为整形,长整形,浮点型,以及复数.在python3中都是整形和长整形都称之为整形,且python3中没有限制. 1.int方法使用,用于转换字 ...

  7. Chrome插件:弹出桌面通知

    if (window.Notification) { var popNotice = function() { if (Notification.permission == "granted ...

  8. kill -9 ,kill -12,kill -15

    https://www.cnblogs.com/liuhouhou/p/5400540.html Linux kill -9 和 kill -15 的区别 大家对kill -9 肯定非常熟悉,在工作中 ...

  9. 'pip' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

    之前python2.7是没有pip的,需要安装python3.6 以上. 但是安装3.6版本后,还是一样.官网提示需要执行以下命令:python -m ensurepip --default-pip ...

  10. redis中key的过期键删除策略

    Redis过期键删除策略 Redis key过期的方式有三种: 被动删除:当读/写一个已经过期的key时,会触发惰性删除策略,直接删除掉这个过期key 主动删除:由于惰性删除策略无法保证冷数据被及时删 ...