Skip to content

Commit a5781dc

Browse files
author
Bryan Latten
committed
Merge pull request #46 from bryanlatten/named-pipes
Pipes: head-slapping unix pipe work
2 parents 78318f2 + 0f27c32 commit a5781dc

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
<?php
22

33
// NOTE: this file+folder should be replaced by the child app
4+
$stdout = fopen( "php://stdout", 'w' );
5+
$stderr = fopen( "php://stderr", 'w' );
6+
7+
fwrite( $stdout, 'Using STDOUT pipe for output' );
8+
fwrite( $stderr, 'Using STDERR pipe for output' );
9+
410
phpinfo();

container/root/run.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,20 @@ else
5555
sed -i "s/pm.min_spare_servers = [0-9]\+/pm.min_spare_servers = 4/" /etc/php5/fpm/pool.d/www.conf
5656
sed -i "s/pm.max_spare_servers = [0-9]\+/pm.max_spare_servers = 32/" /etc/php5/fpm/pool.d/www.conf
5757

58-
# Allow php5-fpm process to pick up stdout and stderr from worker processes
58+
# php5-fpm processes must pick up stdout/stderr from workers, will cause minor performance decrease (but is required)
5959
sed -i "s/;catch_workers_output/catch_workers_output/" /etc/php5/fpm/pool.d/www.conf
6060

61+
62+
# 1. runs php5-fpm as foreground (-F)
63+
# 2. forcing php5-fpm to log to stderr even if a non-terminal is attached (-O)
64+
# 3. redirect stderr to stdout
65+
# 4. filtering the garbage string that PHP-FPM for no-reason-at-all decided to wrap the message in,
66+
# 5. reconnecting the stdout to current stdout
67+
# 6. backgrounding that process
6168
echo 'Starting PHP-FPM (background)'
62-
# php5-fpm --nodaemonize 1> >(sed -u 's/WARNING: \[pool www\] child [0-9]* said into stdout: \"\(.*\)\"$/\1/' >/dev/stdout) \
63-
# 2> >(sed -u 's/WARNING: \[pool www\] child [0-9]* said into stderr: \"\(.*\)\"$/\1/' >/dev/stderr) &
64-
php5-fpm --nodaemonize &
69+
php5-fpm -F -O 2>&1 | sed -u 's/WARNING: \[pool www\] child [0-9]* said into std[a-z]*: \"\(.*\)\"$/\1/' 1>&1 &
6570

6671
echo "Starting Nginx (foreground)"
6772
exec /usr/sbin/nginx -g "daemon off;"
6873

69-
7074
fi

0 commit comments

Comments
 (0)