Tue, 02 Apr 2013 20:44:50 +0200
Correct initial database generation and improve runcommand script logic.
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@767 | 7 | chiliproj_enable="$openpkg_rc_def" |
michael@767 | 8 | chiliproj_cleartext"="yes" |
michael@767 | 9 | chiliproj_tlsecured"="no" |
michael@767 | 10 | #chiliproj_flags="-u @l_nusr@ -g @l_musr@" |
michael@767 | 11 | chiliproj_flags="" |
michael@767 | 12 | chiliproj_host="localhost" |
michael@767 | 13 | chiliproj_port_clt=80 |
michael@767 | 14 | chiliproj_port_tls=443 |
michael@767 | 15 | chiliproj_svcs=1 |
michael@767 | 16 | chiliproj_key="@l_prefix@/etc/openssl/host-ca-rsa-4096-key.pem" |
michael@767 | 17 | chiliproj_crt="@l_prefix@/etc/openssl/host-ca-rsa-4096-crt.pem" |
michael@767 | 18 | chiliproj_log_prolog="true" |
michael@767 | 19 | chiliproj_log_epilog="true" |
michael@767 | 20 | chiliproj_log_numfiles="10" |
michael@767 | 21 | chiliproj_log_minsize="1M" |
michael@767 | 22 | chiliproj_log_complevel="9" |
michael@767 | 23 | chiliproj_logfile="@l_prefix@/lib/chiliproj/log/production.log" |
michael@767 | 24 | chiliproj_thinpath="@l_prefix@/var/chiliproj" |
michael@765 | 25 | |
michael@765 | 26 | %common |
michael@767 | 27 | chiliproj_pidpath="@l_prefix@/var/chiliproj" |
michael@767 | 28 | chiliproj_signal () { |
michael@767 | 29 | for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do |
michael@765 | 30 | [ -f $thepid ] && kill -$1 `cat $thepid` |
michael@765 | 31 | proclive=$? |
michael@765 | 32 | if [ $proclive = 0 ]; then break; fi |
michael@765 | 33 | done |
michael@765 | 34 | [ $proclive = 0 ] |
michael@765 | 35 | } |
michael@764 | 36 | |
michael@764 | 37 | %status -u @l_susr@ -o |
michael@767 | 38 | chiliproj_usable="unknown" |
michael@767 | 39 | chiliproj_active="no" |
michael@765 | 40 | rcService chiliproj enable yes && \ |
michael@767 | 41 | chiliproj_signal 0 && chiliproj_active="yes" |
michael@767 | 42 | echo "chiliproj_enable=\"$chiliproj_enable\"" |
michael@767 | 43 | echo "chiliproj_usable=\"$chiliproj_usable\"" |
michael@767 | 44 | echo "chiliproj_active=\"$chiliproj_active\"" |
michael@764 | 45 | |
michael@765 | 46 | %start -u @l_susr@ |
michael@764 | 47 | rcService chiliproj enable yes || exit 0 |
michael@764 | 48 | rcService chiliproj active yes && exit 0 |
michael@767 | 49 | if [ "$chiliproj_cleartext" = "yes" ]; then |
michael@767 | 50 | cd @l_chilipath@ && \ |
michael@767 | 51 | @l_gempath@/bin/bundle exec thin \ |
michael@767 | 52 | -d \ |
michael@767 | 53 | -e production \ |
michael@767 | 54 | -a $chiliproj_host \ |
michael@767 | 55 | -p $chiliproj_port_clt \ |
michael@767 | 56 | -s $chiliproj_svcs \ |
michael@767 | 57 | -P $chiliproj_pidpath/thind.pid \ |
michael@767 | 58 | -l $chiliproj_thinpath/thind.log \ |
michael@767 | 59 | $chiliproj_flags \ |
michael@767 | 60 | start |
michael@767 | 61 | fi |
michael@767 | 62 | if [ "$chiliproj_tlsecured" = "yes" ]; then |
michael@767 | 63 | cd @l_prefix@/lib/chiliproj && \ |
michael@767 | 64 | @l_gempath@/bin/bundle exec thin \ |
michael@767 | 65 | -d \ |
michael@767 | 66 | -e production \ |
michael@767 | 67 | -a $chiliproj_host \ |
michael@767 | 68 | -p $chiliproj_port_tls \ |
michael@767 | 69 | -s $chiliproj_svcs \ |
michael@767 | 70 | -P $chiliproj_pidpath/thind.pid \ |
michael@767 | 71 | -l $chiliproj_thinpath/thind.log \ |
michael@767 | 72 | --ssl \ |
michael@767 | 73 | --ssl-key-file $chiliproj_key \ |
michael@767 | 74 | --ssl-cert-file $chiliproj_crt \ |
michael@767 | 75 | $chiliproj_flags \ |
michael@767 | 76 | start |
michael@767 | 77 | fi |
michael@764 | 78 | |
michael@765 | 79 | %stop -u @l_susr@ |
michael@764 | 80 | rcService chiliproj enable yes || exit 0 |
michael@764 | 81 | rcService chiliproj active no && exit 0 |
michael@766 | 82 | cd @l_chilipath@ |
michael@767 | 83 | for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do |
michael@766 | 84 | cd @l_prefix@/lib/chiliproj |
michael@766 | 85 | @l_gempath@/bin/bundle exec thin -P $thepid stop |
michael@766 | 86 | done |
michael@764 | 87 | |
michael@765 | 88 | %restart -u @l_susr@ |
michael@764 | 89 | rcService chiliproj enable yes || exit 0 |
michael@764 | 90 | rcService chiliproj active no && exit 0 |
michael@765 | 91 | rc chiliproj stop |
michael@765 | 92 | sleep 2 |
michael@765 | 93 | rc chiliproj start |
michael@764 | 94 | |
michael@765 | 95 | %daily -u @l_susr@ |
michael@764 | 96 | rcService chiliproj enable yes || exit 0 |
michael@765 | 97 | rcTmp -i |
michael@765 | 98 | hintfile=`rcTmp -f -n hint` |
michael@765 | 99 | shtool rotate -f \ |
michael@767 | 100 | -n ${chiliproj_log_numfiles} -s ${chiliproj_log_minsize} -d \ |
michael@767 | 101 | -z ${chiliproj_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ |
michael@767 | 102 | -P "${chiliproj_log_prolog}" \ |
michael@767 | 103 | -E "${chiliproj_log_epilog}; echo 1 >$hintfile" \ |
michael@767 | 104 | ${chiliproj_logfile} |
michael@765 | 105 | shtool rotate -f \ |
michael@767 | 106 | -n ${chiliproj_thin_numfiles} -s ${chiliproj_thin_minsize} -d \ |
michael@767 | 107 | -z ${chiliproj_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ |
michael@767 | 108 | -P "${chiliproj_thin_prolog}" \ |
michael@767 | 109 | -E "${chiliproj_thin_epilog}; echo 1 >$hintfile" \ |
michael@767 | 110 | ${chiliproj_thinpath}/thind.*.log |
michael@765 | 111 | if [ -s $hintfile ]; then |
michael@765 | 112 | rc chiliproj restart |
michael@765 | 113 | fi |
michael@765 | 114 | rcTmp -k |
michael@764 | 115 |