Browse Source

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
changes/04/527204/4
Jeremy Stanley 1 year ago
parent
commit
e2743a3529
2 changed files with 12 additions and 1 deletions
  1. 11
    0
      manifests/worker.pp
  2. 1
    1
      templates/jenkins-subunit-worker.init.erb

+ 11
- 0
manifests/worker.pp View File

@@ -96,6 +96,17 @@ if ! defined(File['/var/log/subunit2sql']) {
96 96
     ],
97 97
   }
98 98
 
99
+  if ($::operatingsystem == 'Ubuntu') and ($::operatingsystemrelease >= '16.04') {
100
+    # This is a hack to make sure that systemd is aware of the new service
101
+    # before we attempt to start it.
102
+    exec { "jenkins-subunit-worker${suffix}-systemd-daemon-reload":
103
+      command     => '/bin/systemctl daemon-reload',
104
+      before      => Service["jenkins-subunit-worker${suffix}"],
105
+      subscribe   => File["/etc/init.d/jenkins-subunit-worker${suffix}"],
106
+      refreshonly => true,
107
+    }
108
+  }
109
+
99 110
   service { "jenkins-subunit-worker${suffix}":
100 111
     enable     => true,
101 112
     hasrestart => true,

+ 1
- 1
templates/jenkins-subunit-worker.init.erb View File

@@ -1,6 +1,6 @@
1 1
 #! /bin/sh
2 2
 ### BEGIN INIT INFO
3
-# Provides:          jenkins-subunit-worker
3
+# Provides:          jenkins-subunit-worker<%= suffix %>
4 4
 # Required-Start:    $remote_fs $syslog
5 5
 # Required-Stop:     $remote_fs $syslog
6 6
 # Default-Start:     2 3 4 5

Loading…
Cancel
Save