diff options
author | Markus Strauss <Markus@ITstrauss.eu> | 2011-11-01 11:54:12 -0400 |
---|---|---|
committer | Markus Strauss <Markus@ITstrauss.eu> | 2011-11-01 11:54:12 -0400 |
commit | 4725e08f1872d914c258ef0159389c76dba97f31 (patch) | |
tree | 2134f0c253dff5968d7c0ac27988796979bf6ae0 | |
parent | 67a3bcd0e562b2f06503d8d582c097ea7fa4dc89 (diff) | |
parent | e4e4a1840b1c26604e1517f06024123a0446338f (diff) | |
download | puppet-runit-4725e08f1872d914c258ef0159389c76dba97f31.tar.gz puppet-runit-4725e08f1872d914c258ef0159389c76dba97f31.tar.bz2 |
Merge branch 'master' of https://github.com/mstrauss/puppet-runit
Conflicts:
manifests/service.pp
-rw-r--r-- | README.rdoc | 22 | ||||
-rw-r--r-- | manifests/service.pp | 27 | ||||
-rw-r--r-- | templates/finish.erb | 3 |
3 files changed, 49 insertions, 3 deletions
diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..559c3d2 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,22 @@ += README +Author:: Markus Strauss (mailto:markus@itstrauss.eu) +Version:: 0.1, 2011-10-27 + +This is a very basic module to manage the runit[http://smarden.org/runit/] service supervisor. + +== Example Usage + + class { 'runit': } + + # define a environment variable, placed under /etc/sv/diaspora_worker/env/QUEUE + runit::env { 'QUEUE': service => 'diaspora_worker' } + + # define a service unter /etc/sv/diaspora_worker + runit::service { "diaspora_worker": + user => diaspora, # service user and group + group => diaspora, + rundir => '/var/rails/diaspora', # service run directory + command => 'bundle exec rake resque:work', # command to start the service + enable => true, # enabling the service by + # linking it to /etc/services/ + } diff --git a/manifests/service.pp b/manifests/service.pp index 54b10ad..85a7ec5 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,20 +3,32 @@ define runit::service ( $group = root, # the service's group name $enable = true, # shall the service be linked to /etc/service $ensure = present, # shall the service be present in /etc/sv - # either one of these three must be declared - it defines the content of the run script /etc/sv/$name/run + # start command - either one of these three must be declared - it defines the content of the run script /etc/sv/$name/run $command = undef, # the most simple way; just state command here - it may not daemonize itself, # but rather stay in the foreground; all output is logged automatically to $logdir/current # this uses a default template which provides logging $source = undef, # specify a source file on your puppet master $content = undef, # specify the content directly (mostly via 'template') + # finish command - defines the content of the finish script /etc/sv/$name/finish + $finish_command = '', + $finish_source = undef, + $finish_content = undef, # service directory - this is required if you use 'command' $rundir = undef, # logging stuff $logger = true, # shall we setup an logging service; if you use 'command' before, # all output from command will be logged automatically to $logdir/current - $logdir = "${rundir}/log", + $_logdir = undef, $timeout = 7 # service restart/stop timeouts (only relevant for 'enabled' services) ) { + + # using the following construct, because '$logdir = "${rundir}/log"' in the + # define statement produces compilation warnings + if $_logdir == undef { + $logdir = "${rundir}/log" + } else { + $logdir = $_logdir + } # FixMe: Validate parameters # fail("Only one of 'command', 'content', or 'source' parameters is allowed") @@ -57,8 +69,17 @@ define runit::service ( ensure => $ensure, mode => 755, ; + "${svbase}/finish": + content => $finish_content ? { + undef => template('runit/finish.erb'), + default => $finish_content, + }, + source => $finish_source, + ensure => $ensure, + mode => 755, + ; } - + # eventually enabling/disabling the service if $enable == true { debug( "Service ${name}: ${_ensure_enabled}" ) diff --git a/templates/finish.erb b/templates/finish.erb new file mode 100644 index 0000000..787a174 --- /dev/null +++ b/templates/finish.erb @@ -0,0 +1,3 @@ +#!/bin/bash +echo "Stopping <%= name %>" +<%= finish_command %> |