From 22946cbbade150e9a3d8e7d0c0b1ad585182b30f Mon Sep 17 00:00:00 2001 From: Markus Strauss Date: Sun, 30 Oct 2011 17:07:21 -0400 Subject: moving the $logdir default value out of the definition to avoid compilation warnings --- manifests/service.pp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index 0fed6d9..5d7d928 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -14,8 +14,16 @@ define runit::service ( # 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 ) { + + # 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") -- cgit v1.2.3 From c8ce27d10ebdfc91de5579c47c808a1d41b94223 Mon Sep 17 00:00:00 2001 From: Markus Strauss Date: Sun, 30 Oct 2011 17:41:19 -0400 Subject: added ability to configure the finish script and provide a simple default one --- manifests/service.pp | 17 +++++++++++++++-- templates/finish.erb | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 templates/finish.erb diff --git a/manifests/service.pp b/manifests/service.pp index 5d7d928..4f886cf 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -3,12 +3,16 @@ 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 @@ -63,8 +67,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 the service if $ensure == present and $enable == true { $_ensure_enabled = present 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 %> -- cgit v1.2.3 From c848cb5fad688dafc1af3e2fdfee77ea1d380f3c Mon Sep 17 00:00:00 2001 From: Markus Strauss Date: Sun, 30 Oct 2011 17:50:10 -0400 Subject: added a simple readme --- README.asciidoc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 README.asciidoc diff --git a/README.asciidoc b/README.asciidoc new file mode 100644 index 0000000..3dd0418 --- /dev/null +++ b/README.asciidoc @@ -0,0 +1,27 @@ +README +====== +Markus Strauss +v0.1, 2011-10-27 + +This is a very basic module to manage the http://smarden.org/runit/[runit] service supervisor. + +Example Usage +^^^^^^^^^^^^^ + +[source,txt] +--------------------------------------------------------------------- +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/ +} +--------------------------------------------------------------------- -- cgit v1.2.3 From e4e4a1840b1c26604e1517f06024123a0446338f Mon Sep 17 00:00:00 2001 From: Markus Strauss Date: Tue, 1 Nov 2011 11:37:35 -0400 Subject: asciidoc is not well supported on GitHub, moved to rdoc --- README.asciidoc | 27 --------------------------- README.rdoc | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 27 deletions(-) delete mode 100644 README.asciidoc create mode 100644 README.rdoc diff --git a/README.asciidoc b/README.asciidoc deleted file mode 100644 index 3dd0418..0000000 --- a/README.asciidoc +++ /dev/null @@ -1,27 +0,0 @@ -README -====== -Markus Strauss -v0.1, 2011-10-27 - -This is a very basic module to manage the http://smarden.org/runit/[runit] service supervisor. - -Example Usage -^^^^^^^^^^^^^ - -[source,txt] ---------------------------------------------------------------------- -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/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/ + } -- cgit v1.2.3