Systemd Service Type

  

 

forking类型

使用Type=forking时,要求ExecStart启动的命令自身就是以daemon模式运行的。
而以daemon模式运行的进程都有一个特性:总是会有一个瞬间退出的中间父进程,
例如,nginx命令默认以daemon模式运行,所以可直接将其配置为forking类型:

 

simple类型

Type=simple是一种最常见的通过systemd服务系统运行用户自定义命令的类型,也是省略Type指令时的默认类型。
Type=simple类型的服务只适合那些在shell下运行在前台的命令。也就是说,当一个命令本身会以daemon模式运行时,将不能使用simple,而应该使用Type=forking。比如ls命令、sleep命令、非daemon模式运行的nginx进程以及那些以前台调试模式运行的进程,在理论上都可以定义为simple类型的服务。

 


If set to forking, it is expected that the process configured with ExecStart= will call fork() as part of its start-up. The parent process is expected to exit when
start-up is complete and all communication channels are set up. The child continues to run as the main service process, and the service manager will consider the
unit started when the parent process exits. .......
posted @   ascertain  阅读(1251)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2020-11-02 MySQL查看当前数据库 和 用户
2020-11-02 cmd xcopy
2020-11-02 shell miscellanies
点击右上角即可分享
微信分享提示