我正在为CoreOS在一个云配置文件中配置systemd。如果我正确理解了这一点,我有两种方法在启动时启动一个单元:
备选方案1,使用[Install]-section (如数字海洋导轨中所述):
- name: initialize_data
content: |
[Unit]
Description=Run a command
[Service]
Type=oneshot
ExecStart=/usr/bin/mkdir /foo
[Install]
WantedBy=multi-user.target备选方案2,删除[Install]-section并使用command: start:
- name: initialize_data
command: start
content: |
[Unit]
Description=Run a command
[Service]
Type=oneshot
ExecStart=/usr/bin/mkdir /foo使用command: start启动单元有什么缺点吗?我明白了,我无法控制它会从哪一个单元开始,但是还有别的吗?它会尊重[Unit]-directives,如Requires=和After=吗?
发布于 2017-03-15 17:15:03
它出现在CoreOS上,差别很小。当在其他Linux发行版上使用systemd时,区别在于start只启动服务,而不会导致它在引导时启动。这就是enable通过处理systemd文件的[Install]部分所做的事情。
但是,CoreOS文档说,cloud-config命令是在每次引导时处理的。因此,通过通过start通过cloud-config指定一个服务,该服务基本上也被启用了。
CoreOS可能包括两种选项,从而使您能够完全灵活地访问两个systemd特性。
https://serverfault.com/questions/838465
复制相似问题