.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
相关推荐
Lingbug几秒前
.Net日志组件之NLog的使用和配置
后端·c#·.net·.netcore
C语言扫地僧8 分钟前
Docker 镜像制作(Dockerfile)
linux·服务器·docker·容器
Xinan_____16 分钟前
Linux——高流量 高并发(访问场景) 高可用(架构要求)
linux·运维·架构
HPC_fac1305206781616 分钟前
RTX 4090 系列即将停产,RTX 5090 系列蓄势待发
服务器·人工智能·gpu算力
周伯通*25 分钟前
Windows上,使用远程桌面连接Ubuntu
linux·windows·ubuntu
Spring-wind1 小时前
【linux】 date命令
linux
稳联技术1 小时前
汽车焊机数据通信:Profinet转Canopen网关的神奇连接
服务器·网络·汽车
钡铼技术物联网关1 小时前
Codesys 与 ARMxy ARM 工业控制器:工业控制的黄金组合
linux·运维·服务器·arm开发·硬件工程
Reuuse2 小时前
【HCIA-Datacom】华为VRP系统
服务器·网络·华为
轩轶子2 小时前
【C-项目】网盘(一期,线程池版)
服务器·c语言