chiliproj/rc.chiliproj

changeset 767
3ee660c5bc4f
parent 766
fd2bc92f4dee
child 774
9024b850a1f9
equal deleted inserted replaced
2:f989546725b9 3:dcd0f53b7462
2 ## 2 ##
3 ## rc.chiliproj -- Run-Commands 3 ## rc.chiliproj -- Run-Commands
4 ## 4 ##
5 5
6 %config 6 %config
7 chili_enable="$openpkg_rc_def" 7 chiliproj_enable="$openpkg_rc_def"
8 chili_host="localhost" 8 chiliproj_cleartext"="yes"
9 chili_port=3000 9 chiliproj_tlsecured"="no"
10 chili_svcs=1 10 #chiliproj_flags="-u @l_nusr@ -g @l_musr@"
11 chili_log_prolog="true" 11 chiliproj_flags=""
12 chili_log_epilog="true" 12 chiliproj_host="localhost"
13 chili_log_numfiles="10" 13 chiliproj_port_clt=80
14 chili_log_minsize="1M" 14 chiliproj_port_tls=443
15 chili_log_complevel="9" 15 chiliproj_svcs=1
16 chili_logfile="@l_prefix@/lib/chiliproj/log/production.log" 16 chiliproj_key="@l_prefix@/etc/openssl/host-ca-rsa-4096-key.pem"
17 chili_thinpath="@l_prefix@/var/chiliproj" 17 chiliproj_crt="@l_prefix@/etc/openssl/host-ca-rsa-4096-crt.pem"
18 chiliproj_log_prolog="true"
19 chiliproj_log_epilog="true"
20 chiliproj_log_numfiles="10"
21 chiliproj_log_minsize="1M"
22 chiliproj_log_complevel="9"
23 chiliproj_logfile="@l_prefix@/lib/chiliproj/log/production.log"
24 chiliproj_thinpath="@l_prefix@/var/chiliproj"
18 25
19 %common 26 %common
20 chili_pidpath="@l_prefix@/var/chiliproj" 27 chiliproj_pidpath="@l_prefix@/var/chiliproj"
21 chili_signal () { 28 chiliproj_signal () {
22 for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do 29 for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do
23 [ -f $thepid ] && kill -$1 `cat $thepid` 30 [ -f $thepid ] && kill -$1 `cat $thepid`
24 proclive=$? 31 proclive=$?
25 if [ $proclive = 0 ]; then break; fi 32 if [ $proclive = 0 ]; then break; fi
26 done 33 done
27 [ $proclive = 0 ] 34 [ $proclive = 0 ]
28 } 35 }
29 36
30 %status -u @l_susr@ -o 37 %status -u @l_susr@ -o
31 chili_usable="unknown" 38 chiliproj_usable="unknown"
32 chili_active="no" 39 chiliproj_active="no"
33 rcService chiliproj enable yes && \ 40 rcService chiliproj enable yes && \
34 chili_signal 0 && chili_active="yes" 41 chiliproj_signal 0 && chiliproj_active="yes"
35 echo "chili_enable=\"$chili_enable\"" 42 echo "chiliproj_enable=\"$chiliproj_enable\""
36 echo "chili_usable=\"$chili_usable\"" 43 echo "chiliproj_usable=\"$chiliproj_usable\""
37 echo "chili_active=\"$chili_active\"" 44 echo "chiliproj_active=\"$chiliproj_active\""
38 45
39 %start -u @l_susr@ 46 %start -u @l_susr@
40 rcService chiliproj enable yes || exit 0 47 rcService chiliproj enable yes || exit 0
41 rcService chiliproj active yes && exit 0 48 rcService chiliproj active yes && exit 0
42 #--ssl 49 if [ "$chiliproj_cleartext" = "yes" ]; then
43 #--ssl-verify 50 cd @l_chilipath@ && \
44 #--ssl-key-file <path> 51 @l_gempath@/bin/bundle exec thin \
45 #--ssl-cert-file <path> 52 -d \
46 cd @l_chilipath@ && \ 53 -e production \
47 @l_gempath@/bin/bundle exec thin \ 54 -a $chiliproj_host \
48 -d \ 55 -p $chiliproj_port_clt \
49 -e production \ 56 -s $chiliproj_svcs \
50 -u @l_nusr@ \ 57 -P $chiliproj_pidpath/thind.pid \
51 -g @l_mgrp@ \ 58 -l $chiliproj_thinpath/thind.log \
52 -a $chili_host \ 59 $chiliproj_flags \
53 -p $chili_port \ 60 start
54 -s $chili_svcs \ 61 fi
55 -P $chili_pidpath/thind.pid \ 62 if [ "$chiliproj_tlsecured" = "yes" ]; then
56 -l $chili_thinpath/thind.log \ 63 cd @l_prefix@/lib/chiliproj && \
57 start 64 @l_gempath@/bin/bundle exec thin \
65 -d \
66 -e production \
67 -a $chiliproj_host \
68 -p $chiliproj_port_tls \
69 -s $chiliproj_svcs \
70 -P $chiliproj_pidpath/thind.pid \
71 -l $chiliproj_thinpath/thind.log \
72 --ssl \
73 --ssl-key-file $chiliproj_key \
74 --ssl-cert-file $chiliproj_crt \
75 $chiliproj_flags \
76 start
77 fi
58 78
59 %stop -u @l_susr@ 79 %stop -u @l_susr@
60 rcService chiliproj enable yes || exit 0 80 rcService chiliproj enable yes || exit 0
61 rcService chiliproj active no && exit 0 81 rcService chiliproj active no && exit 0
62 cd @l_chilipath@ 82 cd @l_chilipath@
63 for thepid in ${chili_pidpath}/thind.[0-9][0-9]*.pid; do 83 for thepid in ${chiliproj_pidpath}/thind.[0-9][0-9]*.pid; do
64 cd @l_prefix@/lib/chiliproj 84 cd @l_prefix@/lib/chiliproj
65 @l_gempath@/bin/bundle exec thin -P $thepid stop 85 @l_gempath@/bin/bundle exec thin -P $thepid stop
66 done 86 done
67 87
68 %restart -u @l_susr@ 88 %restart -u @l_susr@
75 %daily -u @l_susr@ 95 %daily -u @l_susr@
76 rcService chiliproj enable yes || exit 0 96 rcService chiliproj enable yes || exit 0
77 rcTmp -i 97 rcTmp -i
78 hintfile=`rcTmp -f -n hint` 98 hintfile=`rcTmp -f -n hint`
79 shtool rotate -f \ 99 shtool rotate -f \
80 -n ${chili_log_numfiles} -s ${chili_log_minsize} -d \ 100 -n ${chiliproj_log_numfiles} -s ${chiliproj_log_minsize} -d \
81 -z ${chili_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ 101 -z ${chiliproj_log_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \
82 -P "${chili_log_prolog}" \ 102 -P "${chiliproj_log_prolog}" \
83 -E "${chili_log_epilog}; echo 1 >$hintfile" \ 103 -E "${chiliproj_log_epilog}; echo 1 >$hintfile" \
84 ${chili_logfile} 104 ${chiliproj_logfile}
85 shtool rotate -f \ 105 shtool rotate -f \
86 -n ${chili_thin_numfiles} -s ${chili_thin_minsize} -d \ 106 -n ${chiliproj_thin_numfiles} -s ${chiliproj_thin_minsize} -d \
87 -z ${chili_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \ 107 -z ${chiliproj_thin_complevel} -m 664 -o @l_nusr@ -g @l_mgrp@ \
88 -P "${chili_thin_prolog}" \ 108 -P "${chiliproj_thin_prolog}" \
89 -E "${chili_thin_epilog}; echo 1 >$hintfile" \ 109 -E "${chiliproj_thin_epilog}; echo 1 >$hintfile" \
90 ${chili_thinpath}/thind.*.log 110 ${chiliproj_thinpath}/thind.*.log
91 if [ -s $hintfile ]; then 111 if [ -s $hintfile ]; then
92 rc chiliproj restart 112 rc chiliproj restart
93 fi 113 fi
94 rcTmp -k 114 rcTmp -k
95 115

mercurial