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