我需要覆盖systemd模板的ExecStartParameter。我已经确认单元文件存在并通过验证。添加unique-name@.service.d/override.conf文件在某些机器上运行良好:
user@prod-west-1604$ systemctl --version | head -1
systemd 229
user@prod-west-1604$ file -b /etc/systemd/system/unique-name@.service
symbolic link to /lib/systemd/system/nginx.service
user@prod-west-1604$ sudo systemctl edit unique-name@.service
# (opens editor as expected)
Run Code Online (Sandbox Code Playgroud)
但是,在运行较新 systemd 版本的机器上,操作失败:
user@prod-east-1810$ systemctl --version | head -1
systemd 239
user@prod-east-1810$ file -b /etc/systemd/system/unique-name@.service
symbolic link to /lib/systemd/system/nginx.service
user@prod-east-1810$ sudo systemctl edit unique-name@.service
Failed to get the load state of unique-name@.service: Unit name unique-name@.service is neither a valid invocation ID nor unit name.
Run Code Online (Sandbox Code Playgroud)
为什么?
这是由v233 中引入并在 v240 中修复的systemd bug引起的。没有必要升级systemd,在大多数情况下,systemctl edit这只不过是以下操作的快捷方式:
sudo mkdir -p /etc/systemd/system/unique-name@.service.d/
sudo vim /etc/systemd/system/unique-name@.service.d/override.conf
Run Code Online (Sandbox Code Playgroud)
即使在该命令不起作用的systemd版本中,覆盖文件也将起作用。systemctl edit不要忘记使用以下命令应用新配置:
sudo systemctl daemon-reload
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5673 次 |
| 最近记录: |