1 |
olemarkus 11/11/18 08:41:13 |
2 |
|
3 |
Modified: php-fpm.init |
4 |
Log: |
5 |
Fixed init script for multislotting. Bug 390307. Thanks to Guillaume Castagnino and Piotr Karbowski for input |
6 |
|
7 |
(Portage version: 2.2.0_alpha71/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.2 dev-lang/php/files/php-fpm.init |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/php/files/php-fpm.init?rev=1.2&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/php/files/php-fpm.init?rev=1.2&content-type=text/plain |
14 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/php/files/php-fpm.init?r1=1.1&r2=1.2 |
15 |
|
16 |
Index: php-fpm.init |
17 |
=================================================================== |
18 |
RCS file: /var/cvsroot/gentoo-x86/dev-lang/php/files/php-fpm.init,v |
19 |
retrieving revision 1.1 |
20 |
retrieving revision 1.2 |
21 |
diff -u -r1.1 -r1.2 |
22 |
--- php-fpm.init 26 Jul 2010 13:42:12 -0000 1.1 |
23 |
+++ php-fpm.init 18 Nov 2011 08:41:13 -0000 1.2 |
24 |
@@ -1,8 +1,15 @@ |
25 |
#!/sbin/runscript |
26 |
|
27 |
-PHP_FPM_CONF="/etc/php/fpm-php5/php-fpm.conf" |
28 |
+set_phpvars() { |
29 |
+ PHPSLOT=${SVCNAME#php-fpm-} |
30 |
+ [ ${PHPSLOT} = 'php-fpm' ] && PHPSLOT="$(eselect php show fpm)" |
31 |
|
32 |
-opts="depend start stop reload" |
33 |
+ PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf" |
34 |
+ PHP_FPM_PID="/var/run/php-fpm-${PHPSLOT}.pid" |
35 |
+} |
36 |
+ |
37 |
+extra_commands="depend" |
38 |
+extra_started_commands="reload" |
39 |
|
40 |
depend() { |
41 |
need net |
42 |
@@ -10,13 +17,31 @@ |
43 |
} |
44 |
|
45 |
start() { |
46 |
- ebegin "Starting PHP FastCGI server" |
47 |
- start-stop-daemon --start --exec /usr/bin/php-fpm -- -y "${PHP_FPM_CONF}" |
48 |
- eend $? |
49 |
+ ebegin "Starting PHP FastCGI Process Manager" |
50 |
+ set_phpvars |
51 |
+ start-stop-daemon --start --pidfile ${PHP_FPM_PID} --exec \ |
52 |
+ /usr/lib/${PHPSLOT}/bin/php-fpm -- -y "${PHP_FPM_CONF}" -g "${PHP_FPM_PID}" |
53 |
+ local i=0 |
54 |
+ local timeout=5 |
55 |
+ while [ ! -f ${PHP_FPM_PID} ] && [ $i -le $timeout ]; do |
56 |
+ sleep 1 |
57 |
+ i=$(($i + 1)) |
58 |
+ done |
59 |
+ |
60 |
+ [ $timeout -gt $i ] |
61 |
+ eend $? |
62 |
} |
63 |
|
64 |
stop() { |
65 |
- ebegin "Stopping PHP FastCGI server" |
66 |
- start-stop-daemon --stop --name php-fpm |
67 |
- eend $? |
68 |
+ ebegin "Stopping PHP FastCGI Process Manager" |
69 |
+ set_phpvars |
70 |
+ start-stop-daemon --signal QUIT --stop --exec /usr/lib/${PHPSLOT}/bin/php-fpm --pidfile ${PHP_FPM_PID} |
71 |
+ eend $? |
72 |
+} |
73 |
+ |
74 |
+reload() { |
75 |
+ ebegin "Reloading PHP FastCGI Process Manager" |
76 |
+ set_phpvars |
77 |
+ [ -f ${PHP_FPM_PID} ] && kill -USR2 $(cat ${PHP_FPM_PID}) |
78 |
+ eend $? |
79 |
} |