.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
相关推荐
艾醒(AiXing-w)8 分钟前
探索大语言模型(LLM):Ollama快速安装部署及使用(含Linux环境下离线安装)
linux·人工智能·语言模型
垚垚领先11 分钟前
Kdump 文档 - 基于 kexec 的崩溃转储解决方案
linux
tongsound14 分钟前
igh ethercat 实时性测试
linux·c++
柯南二号35 分钟前
【Java后端】Spring Boot 集成雪花算法唯一 ID
java·linux·服务器
半梦半醒*38 分钟前
正则表达式
linux·运维·开发语言·正则表达式·centos·运维开发
mljy.1 小时前
Linux《线程(上)》
linux
Stardep2 小时前
ssh远程连接服务器到vscode上“连接失败”
服务器·vscode·ssh
☆璇2 小时前
【Linux】进程概念(下)
linux·运维·服务器
摘星编程2 小时前
Linux 日志分析:用 ELK 搭建个人运维监控平台
linux·运维·elk·系统监控·性能优化维监
haogexiaole2 小时前
网络操作系统与分布式操作系统的区别
linux