架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 13838|回复: 4

[.NET Core] 【实战】Centos 7 .Net core后台守护进程Supervisor教程

[复制链接]
发表于 2018-6-28 13:54:48 | 显示全部楼层 |阅读模式
ASP.NET Core应用程序发布linux在shell中运行是正常的。可一但shell关闭网站也就关闭了,所以要配置守护进程, 用的是Supervisor,本文主要记录配置的过程和过程遇到的问题

环境

Centos 7 x64位 腾讯云
已安装.Net core 2.1.301

安装Supervisor

QQ截图20180628130628.jpg

配置Supervisor

在etc下创建目录,并赋权限

在目录"/etc/supervisor"下创建配置文件

修改配置文件

在文件末尾添加,注意首尾需无空格,需顶格
supervisord.conf (8.37 KB, 下载次数: 4)

在目录"/etc/supervisor"下创建dotnet core 进程配置文件存放目录"conf.d"

创建进程配置文件

"itsvse"可以为dotnet core 入口dll文件名字,也可以随便起,插入内容,注意首尾需无空格,需顶格:

itsvse.conf (294 Bytes, 下载次数: 2)

[program:MyDotNetName] ;显示名称
command=/bin/bash -c "dotnet test.dll"  ;运行命令,启动dotnet进程
directory=/root/app2/   ;MyDotNetName目录
stderr_logfile=/var/log/MyDotNetName.error.log  ;错误日志文件
stdout_logfile=/var/log/MyDotNetName.stdout.log  ;日志文件
environment=ASPNETCORE_ENVIRONMENT=Production  ;进程环境变量
user=root   ;进程执行用户
autostart=true  ;自动启动 autorestart=true   ;是否自动重启
startsecs=3     ;自动重启间隔时间


创建supervisor 自启动服务


编辑内容:

supervisor.service (292 Bytes, 下载次数: 2)


使配置生效



设置服务开机启动,即设置enable



启动服务


验证dotnet进程是否启动

使用命令"ps -ef | grep dotnet"查看dotnet 是否运行

[root@VM_0_9_centos system]# ps -ef | grep dotnet
root     14924 14922  3 13:34 ?        00:00:01 dotnet test.dll
root     14981 14326  0 13:35 pts/6    00:00:00 grep --color=auto dotnet

QQ截图20180628133602.jpg

supervisor远程管理

使用命令"vim /etc/supervisor/supervisord.conf"修改配置文件,如下设置

重启Supervisor




如下图:

QQ截图20180628135356.jpg





上一篇:非正常关闭vim编辑器后提示错误的解决方法
下一篇:【实战】CentOS 7下将nginx添加到systemctl服务自启动
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2018-11-8 10:34:56 | 显示全部楼层
如果想更新dotnet网站应用,直接把dll文件覆盖到网站目录里面的dll

然后重启Supervisor即可

systemctl restart  supervisor.service
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2018-11-8 10:49:38 | 显示全部楼层
supervisorctl -- control applications run by supervisord from the cmd line.

Usage: /usr/bin/supervisorctl [options] [action [arguments]]

Options:
-c/--configuration -- configuration file path (default /etc/supervisord.conf)
-h/--help -- print usage message and exit
-i/--interactive -- start an interactive shell after executing commands
-s/--serverurl URL -- URL on which supervisord server is listening
     (default "http://localhost:9001").
-u/--username -- username to use for authentication with server
-p/--password -- password to use for authentication with server
-r/--history-file -- keep a readline history (if readline is available)

action [arguments] -- see below

Actions are commands like "tail" or "stop".  If -i is specified or no action is
specified on the command line, a "shell" interpreting actions typed
interactively is started.  Use the action "help" to find out about available
actions.
QQ截图20181108104703.jpg



码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2024-1-1 19:49:17 | 显示全部楼层
其它进程守护:Forever、Pm2 、Supervisor
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2024-3-21 20:39:50 | 显示全部楼层
使用 PM2 启动守护 ASP.NET Core 应用
https://www.itsvse.com/thread-10748-1-1.html
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-4-26 08:01

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表