1.1 --- a/chiliproj/rc.chiliproj Sun Mar 31 17:55:10 2013 +0200 1.2 +++ b/chiliproj/rc.chiliproj Mon Apr 01 19:50:38 2013 +0200 1.3 @@ -6,44 +6,88 @@ 1.4 %config 1.5 chili_enable="$openpkg_rc_def" 1.6 chili_host="localhost" 1.7 + chili_port=3000 1.8 + chili_svcs=1 1.9 chili_log_prolog="true" 1.10 chili_log_epilog="true" 1.11 chili_log_numfiles="10" 1.12 chili_log_minsize="1M" 1.13 chili_log_complevel="9" 1.14 + chili_logfile="@l_prefix@/lib/chiliproj/log/production.log" 1.15 + chili_thinpath="@l_prefix@/var/chiliproj" 1.16 + 1.17 +%common 1.18 + chili_pidpath="@l_prefix@/var/chiliproj" 1.19 + chili_signal () { 1.20 + for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do 1.21 + [ -f $thepid ] && kill -$1 `cat $thepid` 1.22 + proclive=$? 1.23 + if [ $proclive = 0 ]; then break; fi 1.24 + done 1.25 + [ $proclive = 0 ] 1.26 + } 1.27 1.28 %status -u @l_susr@ -o 1.29 chili_usable="unknown" 1.30 - #chili_active="no" 1.31 - chili_active="unknown" 1.32 - # rcService chiliproj enable yes && \ 1.33 - # check pid or something >/dev/null 2>&1 && \ 1.34 - # chili_active="yes" 1.35 + chili_active="no" 1.36 + rcService chiliproj enable yes && \ 1.37 + chili_signal 0 && chili_active="yes" 1.38 echo "chili_enable=\"$chili_enable\"" 1.39 echo "chili_usable=\"$chili_usable\"" 1.40 echo "chili_active=\"$chili_active\"" 1.41 1.42 -%start -u @l_nusr@ 1.43 +%start -u @l_susr@ 1.44 rcService chiliproj enable yes || exit 0 1.45 rcService chiliproj active yes && exit 0 1.46 - PATH=$PATH:@l_gempath@/bin bundle exec thin -e production -a $chili_host start 1.47 +#--ssl 1.48 +#--ssl-verify 1.49 +#--ssl-key-file <path> 1.50 +#--ssl-cert-file <path> 1.51 + cd @l_chilipath@ && \ 1.52 + @l_gempath@/bin/bundle exec thin \ 1.53 + -d \ 1.54 + -e production \ 1.55 + -u @l_nusr@ \ 1.56 + -g @l_mgrp@ \ 1.57 + -a $chili_host \ 1.58 + -p $chili_port \ 1.59 + -s $chili_svcs \ 1.60 + -P $chili_pidpath/thind.pid \ 1.61 + -l $chili_thinpath/thind.log \ 1.62 + start 1.63 1.64 -%stop -u @l_nusr@ 1.65 +%stop -u @l_susr@ 1.66 rcService chiliproj enable yes || exit 0 1.67 rcService chiliproj active no && exit 0 1.68 - # send kill -TERM to pid 1.69 + cd @l_chilipath@ && \ 1.70 + @l_gempath@/bin/bundle exec thin \ 1.71 + -P ${chili_pidpath}/thind.pid stop 1.72 1.73 -%restart -u @l_nusr@ 1.74 +%restart -u @l_susr@ 1.75 rcService chiliproj enable yes || exit 0 1.76 rcService chiliproj active no && exit 0 1.77 - # do stop sleep start 1.78 + rc chiliproj stop 1.79 + sleep 2 1.80 + rc chiliproj start 1.81 1.82 -%daily -u @l_nusr@ 1.83 +%daily -u @l_susr@ 1.84 rcService chiliproj enable yes || exit 0 1.85 -# shtool rotate -f \ 1.86 -# -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ 1.87 -# -z ${chili_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \ 1.88 -# -P "${chili_log_prolog}" \ 1.89 -# -E "${chili_log_epilog}; rc chiliproj logrel" \ 1.90 -# @l_prefix@/lib/chiliproj/log/chiliproject.log 1.91 + rcTmp -i 1.92 + hintfile=`rcTmp -f -n hint` 1.93 + shtool rotate -f \ 1.94 + -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ 1.95 + -z ${chili_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ 1.96 + -P "${chili_log_prolog}" \ 1.97 + -E "${chili_log_epilog}; echo 1 >$hintfile" \ 1.98 + ${chili_logfile} 1.99 + shtool rotate -f \ 1.100 + -n ${chili_thin_numfiles} -s ${chili_thin_minsize} -d \ 1.101 + -z ${chili_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ 1.102 + -P "${chili_thin_prolog}" \ 1.103 + -E "${chili_thin_epilog}; echo 1 >$hintfile" \ 1.104 + ${chili_thinpath}/thind.*.log 1.105 + if [ -s $hintfile ]; then 1.106 + rc chiliproj restart 1.107 + fi 1.108 + rcTmp -k 1.109