【发布时间】:2021-02-01 22:32:46
【问题描述】:
如何在一次主厨运行中实现一次重启/重新加载并符合主厨最佳实践?
使用状态文件是一种好习惯还是重写服务 dnsmasq 信息?
这个问题是 7 年前提出的,有人找到更好的方法吗?
此处记录的重写服务 --
Minimize service restarts from chef notifications?
问题:
当前代码已导致 1 次重新启动和 1 次重新加载。这导致了问题。
dnsmasq 有 3 个配置文件,需要使用不同的启动/重启/重新加载方法进行管理。 dnsmasq 在设计上将 no-poll 作为参数,以防止它在每次更改时重新加载 /etc/resolv.conf。我想在这里控制重载。
package "install dnsmasq" do
name 'dnsmasq'
action :install
notifies :create, 'cookbook_file[/etc/dnsmasq.conf]', :delayed
notifies :create, 'template[/etc/resolv.dnsmasq]', :delayed
notifies :create, 'template[/etc/resolv.conf]', :delayed
notifies :restart, 'service[dnsmasq]', :delayed
end
template '/etc/resolv.dnsmasq' do
...
notifies :reload, 'service[dnsmasq]', :delayed
end
file '/etc/dnsmasq.conf' do
...
notifies :restart, 'service[dnsmasq]', :delayed
end
template '/etc/resolv.conf' do
...
notifies :reload, 'service[dnsmasq]', :delayed
end
service 'dnsmasq' do
supports [:restart, :status, :start, :reload]
action [ :enable, :start ]
reload_command "/usr/bin/killall -s SIGHUP dnsmasq"
end
【问题讨论】:
-
是否需要
:reload,因为还需要服务:restart?恕我直言,在更新所有配置文件后最后重启一次就足够了。 -
在第一次更改或更改 dnsmasq.conf 时更新所有配置将导致重新启动,我们认为这是有风险的。但是,如果我们要更新/更改只需要重新加载的文件,我们希望尽可能避免重新启动服务。
标签: chef-infra dnsmasq