.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
相关推荐
swordbob4 小时前
NIO 的 Channel 里有多个 BIO 吗?
linux·网络·nio
深圳恒讯4 小时前
越南服务器BGP多线和单线有什么区别?
运维·服务器
Fcy6484 小时前
Linux下 信号的保存与捕捉
linux·中断·信号的捕捉·信号的保存
步步为营DotNet5 小时前
基于.NET Aspire 实现云原生应用的高效监控与可观测性
云原生·.net·wpf
A_humble_scholar5 小时前
Linux(九) 进程管理完全指南:从入门到实战
linux·运维·chrome
江华森5 小时前
Linux 操作命令完全指南
linux·运维
咸鱼翻身小阿橙6 小时前
VS2008 + .NET3.5 环境、加热台TCP通讯场景
tcp/ip·php·.net
rjszcb6 小时前
Linux,sensor调试笔记1,修改帧率,以及曝光上不去问题
linux
用什么都重名6 小时前
Git分支合并与远程服务器同步实战:保留关键配置文件
运维·服务器·git
C++ 老炮儿的技术栈6 小时前
Ubuntu root账号自动登陆
linux·运维·服务器·c语言·c++·ubuntu·visual studio