michael@764: #! @l_prefix@/bin/openpkg rc michael@764: ## michael@764: ## rc.chiliproj -- Run-Commands michael@764: ## michael@764: michael@764: %config michael@767: chiliproj_enable="$openpkg_rc_def" michael@774: chiliproj_cleartext="yes" michael@774: chiliproj_tlsecured="no" michael@767: #chiliproj_flags="-u @l_nusr@ -g @l_musr@" michael@767: chiliproj_flags="" michael@767: chiliproj_host="localhost" michael@767: chiliproj_port_clt=80 michael@767: chiliproj_port_tls=443 michael@767: chiliproj_svcs=1 michael@767: chiliproj_key="@l_prefix@/etc/openssl/host-ca-rsa-4096-key.pem" michael@767: chiliproj_crt="@l_prefix@/etc/openssl/host-ca-rsa-4096-crt.pem" michael@767: chiliproj_log_prolog="true" michael@767: chiliproj_log_epilog="true" michael@767: chiliproj_log_numfiles="10" michael@767: chiliproj_log_minsize="1M" michael@767: chiliproj_log_complevel="9" michael@767: chiliproj_logfile="@l_prefix@/lib/chiliproj/log/production.log" michael@767: chiliproj_thinpath="@l_prefix@/var/chiliproj" michael@765: michael@765: %common michael@767: chiliproj_pidpath="@l_prefix@/var/chiliproj" michael@767: chiliproj_signal () { michael@767: for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do michael@765: [ -f $thepid ] && kill -$1 `cat $thepid` michael@765: proclive=$? michael@765: if [ $proclive = 0 ]; then break; fi michael@765: done michael@765: [ $proclive = 0 ] michael@765: } michael@764: michael@764: %status -u @l_susr@ -o michael@767: chiliproj_usable="unknown" michael@767: chiliproj_active="no" michael@765: rcService chiliproj enable yes && \ michael@767: chiliproj_signal 0 && chiliproj_active="yes" michael@767: echo "chiliproj_enable=\"$chiliproj_enable\"" michael@767: echo "chiliproj_usable=\"$chiliproj_usable\"" michael@767: echo "chiliproj_active=\"$chiliproj_active\"" michael@764: michael@765: %start -u @l_susr@ michael@764: rcService chiliproj enable yes || exit 0 michael@764: rcService chiliproj active yes && exit 0 michael@767: if [ "$chiliproj_cleartext" = "yes" ]; then michael@767: cd @l_chilipath@ && \ michael@767: @l_gempath@/bin/bundle exec thin \ michael@767: -d \ michael@767: -e production \ michael@767: -a $chiliproj_host \ michael@767: -p $chiliproj_port_clt \ michael@767: -s $chiliproj_svcs \ michael@767: -P $chiliproj_pidpath/thind.pid \ michael@767: -l $chiliproj_thinpath/thind.log \ michael@767: $chiliproj_flags \ michael@767: start michael@767: fi michael@767: if [ "$chiliproj_tlsecured" = "yes" ]; then michael@767: cd @l_prefix@/lib/chiliproj && \ michael@767: @l_gempath@/bin/bundle exec thin \ michael@767: -d \ michael@767: -e production \ michael@767: -a $chiliproj_host \ michael@767: -p $chiliproj_port_tls \ michael@767: -s $chiliproj_svcs \ michael@767: -P $chiliproj_pidpath/thind.pid \ michael@767: -l $chiliproj_thinpath/thind.log \ michael@767: --ssl \ michael@767: --ssl-key-file $chiliproj_key \ michael@767: --ssl-cert-file $chiliproj_crt \ michael@767: $chiliproj_flags \ michael@767: start michael@767: fi michael@764: michael@765: %stop -u @l_susr@ michael@764: rcService chiliproj enable yes || exit 0 michael@764: rcService chiliproj active no && exit 0 michael@766: cd @l_chilipath@ michael@767: for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do michael@766: cd @l_prefix@/lib/chiliproj michael@766: @l_gempath@/bin/bundle exec thin -P $thepid stop michael@766: done michael@764: michael@765: %restart -u @l_susr@ michael@764: rcService chiliproj enable yes || exit 0 michael@764: rcService chiliproj active no && exit 0 michael@765: rc chiliproj stop michael@765: sleep 2 michael@765: rc chiliproj start michael@764: michael@765: %daily -u @l_susr@ michael@764: rcService chiliproj enable yes || exit 0 michael@765: rcTmp -i michael@765: hintfile=`rcTmp -f -n hint` michael@765: shtool rotate -f \ michael@767: -n ${chiliproj_log_numfiles} -s ${chiliproj_log_minsize} -d \ michael@767: -z ${chiliproj_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ michael@767: -P "${chiliproj_log_prolog}" \ michael@767: -E "${chiliproj_log_epilog}; echo 1 >$hintfile" \ michael@767: ${chiliproj_logfile} michael@765: shtool rotate -f \ michael@767: -n ${chiliproj_thin_numfiles} -s ${chiliproj_thin_minsize} -d \ michael@767: -z ${chiliproj_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ michael@767: -P "${chiliproj_thin_prolog}" \ michael@767: -E "${chiliproj_thin_epilog}; echo 1 >$hintfile" \ michael@767: ${chiliproj_thinpath}/thind.*.log michael@765: if [ -s $hintfile ]; then michael@765: rc chiliproj restart michael@765: fi michael@765: rcTmp -k michael@764: