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.

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

mercurial