cloudware-cookbooks/ktc-collectd — pull request #16 by robertchoi8099 (2014-01-07 06:11:49+00:00)
Title: upgrade to collectd v5

collectd v5 debian package is ready now in the kt repo, so I reverted install type to 'package'.

Have spent some time to figure out runit issue.
During the chef-run, the init script (/etc/init.d/collectd) is installed by package, and then runit service 'collectd' is configured, which creates a symlink from '/etc/init.d/collectd' to '/usr/bin/sv'. On clean install, it's not a problem.

However, in the case where you need to purge collectd packages and re-install it, a problem occurs.
In the collectd cookbook, right after collectd package is installed, it notifies to stop the collectd service (using "Chef::Provider::Service::Init" provider) but if runit process is still running at this time, it immediately creates the symlink mentioned above, which means that now the collectd's init script is just a symlink to runit binary. As a result, the request for stopping the service fails.

So, if you need to re-install collectd package, make sure to remove runit package, too!

{code}
service 'postinst_collectd_init' do
service_name 'collectd'
provider Chef::Provider::Service::Init
action :nothing
end

package "collectd" do
package_name "collectd"
notifies :stop, 'service[postinst_collectd_init]', :immediately
notifies :disable, 'service[postinst_collectd_init]', :immediately
notifies :run, 'execute[kill_collectdmon]', :immediately
end
{code}