Mon, 01 Apr 2013 19:50:38 +0200
Complete packaging along with specification and runcommand improvements.
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@765 | 62 | cd @l_chilipath@ && \ |
michael@765 | 63 | @l_gempath@/bin/bundle exec thin \ |
michael@765 | 64 | -P ${chili_pidpath}/thind.pid stop |
michael@764 | 65 | |
michael@765 | 66 | %restart -u @l_susr@ |
michael@764 | 67 | rcService chiliproj enable yes || exit 0 |
michael@764 | 68 | rcService chiliproj active no && exit 0 |
michael@765 | 69 | rc chiliproj stop |
michael@765 | 70 | sleep 2 |
michael@765 | 71 | rc chiliproj start |
michael@764 | 72 | |
michael@765 | 73 | %daily -u @l_susr@ |
michael@764 | 74 | rcService chiliproj enable yes || exit 0 |
michael@765 | 75 | rcTmp -i |
michael@765 | 76 | hintfile=`rcTmp -f -n hint` |
michael@765 | 77 | shtool rotate -f \ |
michael@765 | 78 | -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ |
michael@765 | 79 | -z ${chili_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ |
michael@765 | 80 | -P "${chili_log_prolog}" \ |
michael@765 | 81 | -E "${chili_log_epilog}; echo 1 >$hintfile" \ |
michael@765 | 82 | ${chili_logfile} |
michael@765 | 83 | shtool rotate -f \ |
michael@765 | 84 | -n ${chili_thin_numfiles} -s ${chili_thin_minsize} -d \ |
michael@765 | 85 | -z ${chili_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ |
michael@765 | 86 | -P "${chili_thin_prolog}" \ |
michael@765 | 87 | -E "${chili_thin_epilog}; echo 1 >$hintfile" \ |
michael@765 | 88 | ${chili_thinpath}/thind.*.log |
michael@765 | 89 | if [ -s $hintfile ]; then |
michael@765 | 90 | rc chiliproj restart |
michael@765 | 91 | fi |
michael@765 | 92 | rcTmp -k |
michael@764 | 93 |