Gentoo Archives: gentoo-commits

From: "Dirkjan Ochtman (djc)" <djc@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in www-servers/nginx/files: nginx.init-r2
Date: Sun, 03 Jan 2010 19:51:43
Message-Id: E1NRWUH-0005eo-EA@stork.gentoo.org
1 djc 10/01/03 19:51:41
2
3 Added: nginx.init-r2
4 Log:
5 Revision bump www-servers/nginx to -r2 (bug 247746 and 272964).
6 (Portage version: 2.1.6.13/cvs/Linux x86_64)
7
8 Revision Changes Path
9 1.1 www-servers/nginx/files/nginx.init-r2
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/nginx/files/nginx.init-r2?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/www-servers/nginx/files/nginx.init-r2?rev=1.1&content-type=text/plain
13
14 Index: nginx.init-r2
15 ===================================================================
16 #!/sbin/runscript
17 # Copyright 1999-2004 Gentoo Foundation
18 # Distributed under the terms of the GNU General Public License v2
19 # $Header: /var/cvsroot/gentoo-x86/www-servers/nginx/files/nginx.init-r2,v 1.1 2010/01/03 19:51:41 djc Exp $
20
21 opts="${opts} upgrade reload configtest"
22
23 depend() {
24 need net
25 use dns logger netmount
26 }
27
28 start() {
29 configtest || return 1
30 ebegin "Starting nginx"
31 start-stop-daemon --start --pidfile /var/run/nginx.pid \
32 --exec /usr/sbin/nginx -- -c /etc/nginx/nginx.conf
33 eend $? "Failed to start nginx"
34 }
35
36 stop() {
37 configtest || return 1
38 ebegin "Stopping nginx"
39 start-stop-daemon --stop --pidfile /var/run/nginx.pid
40 eend $? "Failed to stop nginx"
41 rm -f /var/run/nginx.pid
42 }
43
44 reload() {
45 configtest || return 1
46 ebegin "Refreshing nginx' configuration"
47 kill -HUP `cat /var/run/nginx.pid` &>/dev/null
48 eend $? "Failed to reload nginx"
49 }
50
51 upgrade() {
52 configtest || return 1
53 ebegin "Upgrading nginx"
54
55 einfo "Sending USR2 to old binary"
56 kill -USR2 `cat /var/run/nginx.pid` &>/dev/null
57
58 einfo "Sleeping 3 seconds before pid-files checking"
59 sleep 3
60
61 if [ ! -f /var/run/nginx.pid.oldbin ]; then
62 eerror "File with old pid not found"
63 return 1
64 fi
65
66 if [ ! -f /var/run/nginx.pid ]; then
67 eerror "New binary failed to start"
68 return 1
69 fi
70
71 einfo "Sleeping 3 seconds before WINCH"
72 sleep 3 ; kill -WINCH `cat /var/run/nginx.pid.oldbin`
73
74 einfo "Sending QUIT to old binary"
75 kill -QUIT `cat /var/run/nginx.pid.oldbin`
76
77 einfo "Upgrade completed"
78
79 eend $? "Upgrade failed"
80 }
81
82 configtest() {
83 ebegin "Checking nginx' configuration"
84 /usr/sbin/nginx -c /etc/nginx/nginx.conf -t
85 eend $? "failed, please correct errors above"
86 }