.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
相关推荐
captain37617 分钟前
MyBatis Plus(1)
java·服务器·mybatis
科创致远24 分钟前
ESOP 电子作业指导书 WiFi 网络应用实测报告
运维·服务器·网络
承渊政道31 分钟前
Linux网络学习【从NAT与代理服务理解网络转发、探索内网穿透原理、再到认识DNS与ICMP、最后动手部署并测试内网穿透】
linux·网络·学习·内网穿透·dns·nat
重生之小比特43 分钟前
【Linux系统】17 库制作与原理(下)
linux·运维·服务器
weixin_450907281 小时前
[ZYNQ Linux] VCU使用
linux·zynq
程序员清风1 小时前
AI 编程助手的权限边界:文件、命令、密钥与人工确认
运维·服务器·网络
wacsii1 小时前
【Linux进程(二)】深入 Linux 内核:进程状态切换与底层数据结构的秘密
linux·服务器
R&L_201810011 小时前
LINUX CPU 热点分析
linux
CodeYp20192 小时前
第6讲:Ext 系列文件系统
linux·文件系统·ext
爱吃香菜的初学者2 小时前
十九.Linux——TCP协议(1)
linux·网络·tcp/ip