From e2743a3529f04f7ee088f41dad75a4994a0be259 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 11 Dec 2017 18:19:20 +0000 Subject: [PATCH] Register the worker daemon with systemd When installing a custom initscript for a worker daemon, reload systemd so it will pick that up before attempting to start the service. Wrap it in a conditional check for Ubuntu 16.04 or later, since earlier releases used upstart as their init instead of systemd. Make sure the initscript template uses a distinct "provides" key for each instance of the service as well. This implementation is copied from the puppet-zuul module. Change-Id: I4f7db205ac4ae29953757220dc0b9ae026ebbc71 --- manifests/worker.pp | 11 +++++++++++ templates/jenkins-subunit-worker.init.erb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/manifests/worker.pp b/manifests/worker.pp index c700daa..566964f 100644 --- a/manifests/worker.pp +++ b/manifests/worker.pp @@ -96,6 +96,17 @@ if ! defined(File['/var/log/subunit2sql']) { ], } + if ($::operatingsystem == 'Ubuntu') and ($::operatingsystemrelease >= '16.04') { + # This is a hack to make sure that systemd is aware of the new service + # before we attempt to start it. + exec { "jenkins-subunit-worker${suffix}-systemd-daemon-reload": + command => '/bin/systemctl daemon-reload', + before => Service["jenkins-subunit-worker${suffix}"], + subscribe => File["/etc/init.d/jenkins-subunit-worker${suffix}"], + refreshonly => true, + } + } + service { "jenkins-subunit-worker${suffix}": enable => true, hasrestart => true, diff --git a/templates/jenkins-subunit-worker.init.erb b/templates/jenkins-subunit-worker.init.erb index 08e6551..f77376a 100755 --- a/templates/jenkins-subunit-worker.init.erb +++ b/templates/jenkins-subunit-worker.init.erb @@ -1,6 +1,6 @@ #! /bin/sh ### BEGIN INIT INFO -# Provides: jenkins-subunit-worker +# Provides: jenkins-subunit-worker<%= suffix %> # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5