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