.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
相关推荐
代码论斤卖7 分钟前
OpenHarmony的watchdog service频繁崩溃问题分析
linux·harmonyos
halazi10011 分钟前
WSL 安装与 Ubuntu 24.04 配置使用指南
linux·运维·ubuntu·wsl
2302_8031322520 分钟前
ensp中关于交换机S3700不被识别的错误列举以及vlan 绑定acl后无法删除问题
运维·服务器·网络
拾贰_C20 分钟前
【Ubuntu | Nvidia | driver | installation | commend】
linux·运维·ubuntu
.柒宇.26 分钟前
Linux 时间同步服务:Chrony 深度笔记
linux·运维·服务器
Ww.xh27 分钟前
OpenHarmony API 9 升级到 API 10 权限与接口变更实战指南
服务器·华为·harmonyos
Strugglingler28 分钟前
Linux Device Drivers-第六章 高级字符驱动操作
linux·笔记
zjeweler28 分钟前
云服务器centos7.6搭建个人网站教程
运维·服务器
liyunlong-java32 分钟前
单服务器 MySQL 主从同步部署教程(宝塔 + MySQL 8.0)
服务器·mysql·adb
青瓦梦滋39 分钟前
Linux线程的同步与互斥
linux·c++