.net6 当连接用户的shell断掉后,dotnet会自动关闭,达不到长期运行的效果。.NET 进程守护

1、/etc/systemd/system/ 目录下创建service文件

如:/etc/systemd/system/testDemoSer.service

2、文件内容示例:
html 复制代码
[Unit]
Description=testDemoSer running on CentOS
[Service]
WorkingDirectory=/usr/project/iis
Type=simple
User=root
Group=root
ExecStart=dotnet /usr/project/iis/xxxx.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
SyslogIdentifier=dotnet-example
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
3、 保存文件并启用服务
bash 复制代码
systemctl enable testDemoSer.service
4、启用服务
bash 复制代码
systemctl start testDemoSer.service
5、查看运行状态
bash 复制代码
systemctl status testDemoSer.service
6、systemctl

Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器。

Systemd是一个系统管理守护进程、工具和库的集合,用于取代System V初始进程。Systemd的功能是用于集中管理和配置类UNIX系统。

6.1查看是否安装

bash 复制代码
systemctl --version

6.2查看安装目录

bash 复制代码
whereis systemd
whereis systemctl

6.3检测是否运行

bash 复制代码
ps -eaf | grep [s]ystemd

6.4 分析systemd启动进程

bash 复制代码
systemd-analyze

6.5分析启动时各个进程花费时间

bash 复制代码
systemd-analyze blame
相关推荐
遇见火星2 小时前
Ubuntu Docker 容器化部署教程
linux·ubuntu·docker
ybb_ymm4 小时前
mysql8在linux下的默认规则修改
linux·运维·数据库·mysql
半梦半醒*4 小时前
zabbix安装
linux·运维·前端·网络·zabbix
板鸭〈小号〉5 小时前
Socket网络编程(2)-command_server
运维·服务器
weixin_456904275 小时前
基于.NET Framework 4.0的串口通信
开发语言·c#·.net
武文斌776 小时前
复习总结最终版:单片机
linux·单片机·嵌入式硬件·学习
驱动探索者6 小时前
贝尔实验室发展史:20世纪科技圣殿的辉煌与沉浮
linux
yuyuyui7 小时前
Roslyn 技术解析:如何利用它做代码规范检查与运行时代码生成?
.net
何朴尧7 小时前
centos/cuos如何开启软件源
linux·运维·centos
派阿喵搞电子7 小时前
关于使用docker部署srs服务器的相关指令
服务器·docker·容器