.net6 当连接用户的shell断掉后,dotnet会自动关闭,达不到长期运行的效果。.NET 进程守护

1、/etc/systemd/system/ 目录下创建service文件

如:/etc/systemd/system/testDemoSer.service

2、文件内容示例:
[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、 保存文件并启用服务
systemctl enable testDemoSer.service
4、启用服务
systemctl start testDemoSer.service
5、查看运行状态
systemctl status testDemoSer.service
6、systemctl

Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器。

Systemd是一个系统管理守护进程、工具和库的集合,用于取代System V初始进程。Systemd的功能是用于集中管理和配置类UNIX系统。

6.1查看是否安装

systemctl --version

6.2查看安装目录

whereis systemd
whereis systemctl

6.3检测是否运行

ps -eaf | grep [s]ystemd

6.4 分析systemd启动进程

systemd-analyze

6.5分析启动时各个进程花费时间

systemd-analyze blame

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 07:52:03       99 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 07:52:03       107 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 07:52:03       90 阅读
  4. Python语言-面向对象

    2024-07-10 07:52:03       98 阅读

热门阅读

  1. 摒弃传统分页:移动端开发中的无限滚动实现

    2024-07-10 07:52:03       35 阅读
  2. 程序人生 - (002)

    2024-07-10 07:52:03       35 阅读
  3. MacOS隐藏文件打开指南

    2024-07-10 07:52:03       30 阅读
  4. 基于go 1.19的站点模板爬虫

    2024-07-10 07:52:03       30 阅读
  5. Pandas在生物信息学中的应用详解

    2024-07-10 07:52:03       29 阅读
  6. DOM XMLHttpRequest

    2024-07-10 07:52:03       26 阅读
  7. nginx详解

    2024-07-10 07:52:03       24 阅读
  8. vue实现表单输入框数字类型校验功能

    2024-07-10 07:52:03       39 阅读
  9. 【数据基础】— 基于Go1.19的站点模板爬虫的实现

    2024-07-10 07:52:03       33 阅读