chiliproj/rc.chiliproj

Mon, 01 Apr 2013 20:12:48 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 01 Apr 2013 20:12:48 +0200
changeset 766
fd2bc92f4dee
parent 765
5be956b2db74
child 767
3ee660c5bc4f
permissions
-rw-r--r--

Correct run command stop logic and indicate installation success.

michael@764 1 #! @l_prefix@/bin/openpkg rc
michael@764 2 ##
michael@764 3 ## rc.chiliproj -- Run-Commands
michael@764 4 ##
michael@764 5
michael@764 6 %config
michael@764 7 chili_enable="$openpkg_rc_def"
michael@764 8 chili_host="localhost"
michael@765 9 chili_port=3000
michael@765 10 chili_svcs=1
michael@764 11 chili_log_prolog="true"
michael@764 12 chili_log_epilog="true"
michael@764 13 chili_log_numfiles="10"
michael@764 14 chili_log_minsize="1M"
michael@764 15 chili_log_complevel="9"
michael@765 16 chili_logfile="@l_prefix@/lib/chiliproj/log/production.log"
michael@765 17 chili_thinpath="@l_prefix@/var/chiliproj"
michael@765 18
michael@765 19 %common
michael@765 20 chili_pidpath="@l_prefix@/var/chiliproj"
michael@765 21 chili_signal () {
michael@765 22 for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do
michael@765 23 [ -f $thepid ] && kill -$1 `cat $thepid`
michael@765 24 proclive=$?
michael@765 25 if [ $proclive = 0 ]; then break; fi
michael@765 26 done
michael@765 27 [ $proclive = 0 ]
michael@765 28 }
michael@764 29
michael@764 30 %status -u @l_susr@ -o
michael@764 31 chili_usable="unknown"
michael@765 32 chili_active="no"
michael@765 33 rcService chiliproj enable yes && \
michael@765 34 chili_signal 0 && chili_active="yes"
michael@764 35 echo "chili_enable=\"$chili_enable\""
michael@764 36 echo "chili_usable=\"$chili_usable\""
michael@764 37 echo "chili_active=\"$chili_active\""
michael@764 38
michael@765 39 %start -u @l_susr@
michael@764 40 rcService chiliproj enable yes || exit 0
michael@764 41 rcService chiliproj active yes && exit 0
michael@765 42 #--ssl
michael@765 43 #--ssl-verify
michael@765 44 #--ssl-key-file <path>
michael@765 45 #--ssl-cert-file <path>
michael@765 46 cd @l_chilipath@ && \
michael@765 47 @l_gempath@/bin/bundle exec thin \
michael@765 48 -d \
michael@765 49 -e production \
michael@765 50 -u @l_nusr@ \
michael@765 51 -g @l_mgrp@ \
michael@765 52 -a $chili_host \
michael@765 53 -p $chili_port \
michael@765 54 -s $chili_svcs \
michael@765 55 -P $chili_pidpath/thind.pid \
michael@765 56 -l $chili_thinpath/thind.log \
michael@765 57 start
michael@764 58
michael@765 59 %stop -u @l_susr@
michael@764 60 rcService chiliproj enable yes || exit 0
michael@764 61 rcService chiliproj active no && exit 0
michael@766 62 cd @l_chilipath@
michael@766 63 for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do
michael@766 64 cd @l_prefix@/lib/chiliproj
michael@766 65 @l_gempath@/bin/bundle exec thin -P $thepid stop
michael@766 66 done
michael@764 67
michael@765 68 %restart -u @l_susr@
michael@764 69 rcService chiliproj enable yes || exit 0
michael@764 70 rcService chiliproj active no && exit 0
michael@765 71 rc chiliproj stop
michael@765 72 sleep 2
michael@765 73 rc chiliproj start
michael@764 74
michael@765 75 %daily -u @l_susr@
michael@764 76 rcService chiliproj enable yes || exit 0
michael@765 77 rcTmp -i
michael@765 78 hintfile=`rcTmp -f -n hint`
michael@765 79 shtool rotate -f \
michael@765 80 -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \
michael@765 81 -z ${chili_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \
michael@765 82 -P "${chili_log_prolog}" \
michael@765 83 -E "${chili_log_epilog}; echo 1 >$hintfile" \
michael@765 84 ${chili_logfile}
michael@765 85 shtool rotate -f \
michael@765 86 -n ${chili_thin_numfiles} -s ${chili_thin_minsize} -d \
michael@765 87 -z ${chili_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \
michael@765 88 -P "${chili_thin_prolog}" \
michael@765 89 -E "${chili_thin_epilog}; echo 1 >$hintfile" \
michael@765 90 ${chili_thinpath}/thind.*.log
michael@765 91 if [ -s $hintfile ]; then
michael@765 92 rc chiliproj restart
michael@765 93 fi
michael@765 94 rcTmp -k
michael@764 95

mercurial