From 43668425b403b025c828e67270c568565ccb7733 Mon Sep 17 00:00:00 2001 From: Emile Cantin Date: Wed, 18 Apr 2012 00:59:28 -0400 Subject: [PATCH] Changed the template a bit --- data/export/initscript/master.erb | 76 ++++++++------------------ lib/foreman/export/.initscript.rb.swp | Bin 12288 -> 0 bytes spec/resources/export/initscript/app | 18 +++--- 3 files changed, 31 insertions(+), 63 deletions(-) delete mode 100644 lib/foreman/export/.initscript.rb.swp diff --git a/data/export/initscript/master.erb b/data/export/initscript/master.erb index edb9f0c..bb1bdeb 100644 --- a/data/export/initscript/master.erb +++ b/data/export/initscript/master.erb @@ -18,7 +18,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Runs <%= app %>" NAME=<%= app %> -PIDFILE=/var/run/$NAME.pid +PIDDIR=/var/run/$NAME SCRIPTNAME=/etc/init.d/$NAME # Read configuration variable file if it is present @@ -37,67 +37,35 @@ SCRIPTNAME=/etc/init.d/$NAME # do_start() { - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ - || return 1 - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 - # Add code here, if necessary, that waits for the process to be ready - # to handle requests from services started subsequently which depend - # on this one. As a last resort, sleep for some time. -} - -### START EACH PROCESS -<% engine.procfile.entries.each do |process| %> - <% 1.upto(concurrency[process.name]) do |num| %> - do_start_<%= process.name %>_<%= num %>() - { - # This starts the process - } + mkdir -p $PIDDIR + # START APPLICATION: <%= app %> + <% engine.procfile.entries.each do |process| %> + # START PROCESS: <%= process.name %> + <% 1.upto(concurrency[process.name]) do |num| %> + # START CONCURRENT: <%= num %> + # Code here to start: <%= app %>.<%= process.name %>.<%= num %> + # (Create $PIDDIR/<%= process.name %>.<%= num %>.pid) + <% end %> <% end %> -<% end %> -### + +} # # Function that stops the daemon/service # do_stop() { - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" -} - -### STOP EACH PROCESS -<% engine.procfile.entries.each do |process| %> - <% 1.upto(concurrency[process.name]) do |num| %> - do_stop_<%= process.name %>_<%= num %>() - { - # This starts the process - } + # STOP APPLICATION: <%= app %> + <% engine.procfile.entries.each do |process| %> + # STOP PROCESS: <%= process.name %> + <% 1.upto(concurrency[process.name]) do |num| %> + # STOP CONCURRENT: <%= num %> + # Code here to stop: <%= app %>.<%= process.name %>.<%= num %> + # (Kill $PIDDIR/<%= process.name %>.<%= num %>.pid) + <% end %> <% end %> -<% end %> -### + rmdir $PIDDIR +} case "$1" in start) diff --git a/lib/foreman/export/.initscript.rb.swp b/lib/foreman/export/.initscript.rb.swp deleted file mode 100644 index b2f0d1518490e04760dcd931d907c8a0c47c08ef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&2H2%5XZfg6Hq>{98C7mL~4^l4^#^jscI`#qM{%bB&rg5v)-*sVyBKnDcyxP zK)e9F2=4$#;L3?3;tYs!K6YE6;=}=UBK_B~XPlY&#g}NOJ$-L^gIy2_OL^fCP{L55jkN^@u0!RP} zAOR$R1dzZ#Bfuqm{!mKmk?v?=c-V!$XX-TfY*VulN)CeN9!t}KGf5Mc8Lq=f$*$1l!Bj=CEFIol%oBB;b@! z^|@}ttab{uQpPK4DT=X)QMv?mtQiq!zD`_QR2h=ejO|hz2hGzKZSGn7z#(?u zg3#-KDu2W0EZU?UMf=vfU&cF-1LVKT%%)@sFBsSq{EpCe!41Qu;J3pJvuh;;dpD|n!t-I7$xfI;h$7Qi^@`FVY{ug*w4wKCzfYauG1CD|>K9iy z=NZ?vV{s3j@LCHSjJ3($f~Cm3%`#r3&Sg)?q7oh%rFSdV)~O_%Jc262l-6gadKX$N z?K&%YW@wi3NOX588~QjN&1KB9Y`6lsba=Nq0)#{{1LIQJ5#MSp7A^6u*7C3?o?idm aIuAJ$qWN|%G#ulqpT6ptcSZ(#g2+#ur$_1l diff --git a/spec/resources/export/initscript/app b/spec/resources/export/initscript/app index 15b3466..4c50558 100644 --- a/spec/resources/export/initscript/app +++ b/spec/resources/export/initscript/app @@ -18,7 +18,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Runs app" NAME=app -PIDFILE=/var/run/$NAME.pid +PIDDIR=/var/run/$NAME SCRIPTNAME=/etc/init.d/$NAME # Read configuration variable file if it is present @@ -52,14 +52,14 @@ do_start() } ### START EACH PROCESS - do_start_alpha_1() - { - # This starts the process - } - do_start_bravo_1() - { - # This starts the process - } +do_start_alpha_1() +{ + # This starts the process +} +do_start_bravo_1() +{ + # This starts the process +} ### #