annotate uwsgi.init @ 0:9668c317e887

Initial revision
author Guido Berhoerster <guido+packaging@berhoerster.name>
date Wed, 10 Jul 2013 19:23:16 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
1 #!/bin/sh
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
2 #
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
3 # uwsgi - Manages uWSGI application container server instances
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
4 #
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
5 # chkconfig: - 20 80
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
6 # description: uWSGI Emperor for managing uWSGI application container server \
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
7 # instances
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
8
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
9 ### BEGIN INIT INFO
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
10 # Provides: uwsgi
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
11 # Required-Start: $local_fs $network $remote_fs
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
12 # Required-Stop: $local_fs $network $remote_fs
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
13 # Should-Start:
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
14 # Should-Stop:
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
15 # Default-Start:
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
16 # Default-Stop: 0 1 2 3 4 5 6
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
17 # Short-Description: uWSGI emperor
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
18 # Description: uWSGI Emperor for managing uWSGI application container server
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
19 # instances
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
20 ### END INIT INFO
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
21
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
22 # Source function library.
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
23 . /etc/rc.d/init.d/functions
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
24
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
25 exec="/usr/sbin/uwsgi"
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
26 prog="$(basename "$exec")"
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
27 config="/etc/uwsgi.ini"
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
28
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
29 lockfile=/var/lock/subsys/$prog
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
30 rundir=/var/run/$prog
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
31 pidfile=$rundir/$prog.pid
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
32
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
33 start() {
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
34 mkdir -p $rundir
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
35 chown uwsgi:uwsgi $rundir
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
36 [ -x $exec ] || exit 5
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
37 [ -f $config ] || exit 6
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
38 echo -n $"Starting $prog: "
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
39 daemon --pidfile=$pidfile $exec --ini /etc/uwsgi.ini 2>/dev/null
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
40 retval=$?
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
41 if [ $retval -eq 0 ]; then
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
42 touch $lockfile
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
43 success
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
44 else
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
45 retval=1
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
46 failure
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
47 fi
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
48 echo
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
49 return $retval
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
50 }
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
51
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
52 stop() {
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
53 echo -n $"Stopping $prog: "
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
54 killproc -p $pidfile $prog -QUIT
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
55 retval=$?
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
56 echo
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
57 [ $retval -eq 0 ] && rm -f $lockfile
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
58 return $retval
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
59 }
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
60
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
61 restart() {
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
62 stop
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
63 start
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
64 }
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
65
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
66 reload() {
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
67 echo -n $"Reloading $prog: "
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
68 killproc -p $pidfile $prog -HUP
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
69 retval=$?
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
70 echo
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
71 return $retval
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
72 }
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
73
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
74 force_reload() {
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
75 restart
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
76 }
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
77
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
78 rh_status() {
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
79 # run checks to determine if the service is running or use generic status
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
80 status $prog
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
81 }
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
82
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
83 rh_status_q() {
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
84 rh_status >/dev/null 2>&1
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
85 }
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
86
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
87
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
88 case "$1" in
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
89 start)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
90 rh_status_q && exit 0
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
91 $1
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
92 ;;
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
93 stop)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
94 rh_status_q || exit 0
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
95 $1
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
96 ;;
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
97 restart)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
98 $1
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
99 ;;
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
100 reload)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
101 rh_status_q || exit 7
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
102 $1
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
103 ;;
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
104 force-reload)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
105 force_reload
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
106 ;;
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
107 status)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
108 rh_status
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
109 ;;
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
110 condrestart|try-restart)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
111 rh_status_q || exit 0
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
112 restart
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
113 ;;
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
114 *)
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
115 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
116 exit 2
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
117 esac
9668c317e887 Initial revision
Guido Berhoerster <guido+packaging@berhoerster.name>
parents:
diff changeset
118 exit $?