.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
相关推荐
小李独爱秋8 分钟前
UNIX发展历史与核心技术解析
服务器·操作系统·unix
佩佩(@ 。 @)22 分钟前
网络编程-创建TCP协议服务器
服务器·网络·tcp/ip
蓝黑202029 分钟前
阿里云ECS服务器搭建ThinkPHP环境
服务器·阿里云·thinkphp
G_H_S_3_30 分钟前
【网络运维】Shell 脚本编程:while 循环与 until 循环
linux·运维·网络·shell
liulilittle1 小时前
.NET反射与IL反编译核心技术
开发语言·数据库·c#·.net·反射·反编译·il
coderklaus1 小时前
Shell 基础知识
linux·macos·shell
争不过朝夕,又念着往昔1 小时前
即时通讯项目---网关服务
linux·c++·vscode
时空自由民.2 小时前
linux下camera 详细驱动流程 OV02K10为例(chatgpt版本)
linux·运维·服务器
码界奇点2 小时前
Python内置函数全解析:30个核心函数语法、案例与最佳实践指南
linux·服务器·python
The_Second_Coming2 小时前
Linux 学习笔记 - 集群管理篇
linux·笔记·学习