]> git.pld-linux.org Git - packages/h2o.git/blob - h2o.init
add init scripts, lograote and index page
[packages/h2o.git] / h2o.init
1 #!/bin/bash
2 #
3 # chkconfig: - 85 15
4 # description: H2O - the optimized HTTP/1, HTTP/2 server
5 # processname: h2o
6 # config: /etc/h2o/h2o.conf
7 # pidfile: /var/run/h2o/h2o.pid
8
9 ### BEGIN INIT INFO
10 # Provides: h2o
11 # Required-Start: $local_fs $remote_fs $network $named
12 # Required-Stop: $local_fs $remote_fs $network
13 # Should-Start: distcache
14 # Short-Description: start and stop h2o HTTP Server
15 # Description: H2O - the optimized HTTP/1, HTTP/2 server
16 ### END INIT INFO
17
18 # Source function library.
19 . /etc/rc.d/init.d/functions
20
21 if [ -f /etc/sysconfig/h2o ]; then
22     . /etc/sysconfig/h2o
23 fi
24
25 # Path to the server binary, and short-form for messages.
26 h2o=/usr/sbin/h2o
27 prog=h2o
28 configfile=/etc/h2o/h2o.conf
29 lockfile=${LOCKFILE-/var/lock/subsys/h2o}
30 RETVAL=0
31 options="-m daemon -c $configfile"
32
33 pidfile=`sed -ne 's|pid-file:\s*\([-_./0-9a-zA-Z]\{1,\}\)|\1|p' $configfile`
34 if [ -z "$pidfile" ]; then
35     echo $"pid-file must be defined in $configfile"
36     exit 1
37 fi
38
39 start() {
40     echo -n $"Starting $prog: "
41     daemon --pidfile=${pidfile} $h2o $options
42     RETVAL=$?
43     echo
44     [ $RETVAL = 0 ] && touch ${lockfile}
45     return $RETVAL
46 }
47
48 stop() {
49     echo -n $"Stopping $prog: "
50     killproc -p ${pidfile} $h2o -TERM
51     RETVAL=$?
52     echo
53     [ $RETVAL = 0 ] && rm -f ${lockfile}
54 }
55
56 reload() {
57     echo -n $"Reloading $prog: "
58     if ! $h2o -t -c ${configfile} >&/dev/null; then
59         RETVAL=6
60         echo $"not reloading due to configuration syntax error"
61         failure $"not reloading $h2o due to configuration syntax error"
62     else
63         # Force LSB behaviour from killproc
64         LSB=1 killproc -p ${pidfile} $h2o -HUP
65         RETVAL=$?
66         if [ $RETVAL -eq 7 ]; then
67             failure $"h2o shutdown"
68         fi
69     fi
70     echo
71 }
72
73 configtest() {
74     $h2o -t -c ${configfile}
75 }
76
77 # See how we were called.
78 case "$1" in
79   start)
80         start
81         ;;
82   stop)
83         stop
84         ;;
85   status)
86         status -p ${pidfile} $h2o
87         RETVAL=$?
88         ;;
89   restart)
90         stop
91         start
92         ;;
93   condrestart|try-restart)
94         if status -p ${pidfile} $h2o >&/dev/null; then
95             stop
96             start
97         fi
98         ;;
99   force-reload|reload)
100         reload
101         ;;
102   configtest)
103         configtest
104         RETVAL=$?
105         ;;
106   *)
107         echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|configtest}"
108         RETVAL=2
109 esac
110
111 exit $RETVAL
This page took 0.093618 seconds and 4 git commands to generate.