Bas*_*asj 3 networking systemd services
我想开始我的服务 samplerbox.service
[Unit]
Description=Starts SamplerBox
[Service]
Type=simple
ExecStart=/root/SamplerBox/samplerbox.sh # this script does: python /root/SamplerBox/samplerbox.py
WorkingDirectory=/root/SamplerBox/
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
之前 networking.service(DHCP 事情、IP 归属等)完成。
备注:我的程序根本不使用网络。
这是情节(这里的尺寸更大):
如您所见,samplerbox.service完全等待networking.service完成。(我做了几次测试,结果都是一样的)。
我试过:用WantedBy=multi-user.target其他类似的东西
替换WantedBy=sound.target 然后systemctl disable samplerbox.service重新启用它......但这没有成功!
如何强制服务之前启动networking.service?
samplerbox.service联网完成后启动。
是的,但只是偶然的,而不是实际发生的事情。如果您仔细查看图表,您会发现它samplerbox.service是在basic.target. 这是 systemd 的正常设计和设计。大多数(非系统)服务都设置了“默认依赖项”,即未在服务单元中写出的隐式依赖项和排序。来自的依赖basic.target除非在服务单元中明确禁用了默认值,否则和之后的排序是 systemd 应用的一个这样的默认值。
您还将排序和依赖混为一谈。各种“想要”指令,例如WantedBy您一直在使用的指令及其反向指令Wants,指定依赖项。如果请求启动服务 A,它们会让 systemd 将作业排入队列以启动服务 B。它们没有指定这些作业的顺序。排序由其他设置控制,即相当明显命名的Before和After。
依赖关系指定从一个简单的命令(例如systemctl start graphical.target. 排序指定了这些作业的执行时间和执行顺序。
systemd.unit. systemd 手册页。freedesktop.org。systemd.service. systemd 手册页。freedesktop.org。| 归档时间: |
|
| 查看次数: |
2070 次 |
| 最近记录: |