.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
相关推荐
xingzhemengyou11 天前
LINUX SSH长连接VS短连接
linux
✧˖‹gσσ∂ иιghт›✧1 天前
esp32 s3 修改本地ip和服务器IP
服务器·网络协议·tcp/ip
Ares-Wang1 天前
网络》》防火墙
运维·服务器·网络
可爱又迷人的反派角色“yang”1 天前
k8s(四)
linux·网络·云原生·容器·kubernetes·云计算
朝阳5811 天前
树莓派 Ubuntu 系统登录问题完整指南:解决 Permission denied (publickey)错误
linux·运维·ubuntu
默|笙1 天前
【Linux】基础IO(1)文件、fd
linux·运维·服务器
凌波粒1 天前
Linux高级篇-日志管理/Linux裁剪/内核源码/备份与恢复/可视化管理
linux·运维·服务器
阿杰 AJie1 天前
如何将公司公网ip绑定到服务器和域名
服务器·网络·tcp/ip
米优1 天前
srs媒体流服务器二次开发-实现读取配置文件功能
服务器·后端·媒体
m0_726965981 天前
【服务器二】下载拓展成功
运维·服务器