.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
相关推荐
JhonKI3 分钟前
【Linux网络】深入解析I/O多路转接 - Select
linux·运维·网络
伤不起bb3 分钟前
Nginx 核心功能
linux·服务器·nginx
The-Dog41 分钟前
Linux命令使用记录(自用)
linux
识途老码1 小时前
什么是单臂路由
运维·服务器·网络·单臂路由
Linux运维老纪1 小时前
Ansible 铸就 Linux 安全之盾(Ansible Builds Linux Security Shield)
linux·服务器·网络·安全·云计算·ansible·运维开发
唐青枫2 小时前
Linux apropos 命令使用详解
linux
刘大猫.2 小时前
Centos Ubuntu RedOS系统类型下查看系统信息
linux·ubuntu·centos·ip·ifconfig·redos·查询系统信息
YuSun_WK3 小时前
程序&进程&多任务&线程
linux·运维·服务器
HeLLo_a1194 小时前
第11章 安全网络架构和组件(一)
linux·服务器·网络
南川琼语4 小时前
TCP概念+模拟tcp服务器及客户端
linux·服务器·网络·tcp/ip