-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FPM. access.log with stderr begins to write logs to error_log after daemon reload (GH-8885) #8913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
WoZ
wants to merge
7
commits into
php:master
from
WoZ:8885-fpm-access-log-with-stderr-writes-to-error-log-after-daemon-reload
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2d74d3b
FPM. access.log with stderr begins to write logs to error_log after d…
WoZ c56ca02
FPM. access.log with stderr begins to write logs to error_log after d…
WoZ 16a1b2a
FPM. access.log with stderr begins to write logs to error_log after d…
WoZ f3a5ef3
FPM. access.log with stderr begins to write logs to error_log after d…
WoZ 59d0075
FPM. access.log with stderr begins to write logs to error_log after d…
WoZ c76be3c
FPM. access.log with stderr begins to write logs to error_log after d…
WoZ 37014d4
FPM. access.log with stderr begins to write logs to error_log after d…
WoZ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--TEST-- | ||
FPM: bug8885 - access.log with stderr begins to write logs to error_log after daemon reload (GH-8885) | ||
--SKIPIF-- | ||
<?php | ||
include "skipif.inc"; | ||
FPM\Tester::skipIfRoot(); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once "tester.inc"; | ||
|
||
$cfg = <<<EOT | ||
[global] | ||
error_log = {{FILE:LOG}} | ||
pid = {{FILE:PID}} | ||
[unconfined] | ||
listen = {{ADDR}} | ||
access.log=/proc/self/fd/2 | ||
ping.path = /ping | ||
ping.response = pong | ||
pm = dynamic | ||
pm.max_children = 5 | ||
pm.start_servers = 1 | ||
pm.min_spare_servers = 1 | ||
pm.max_spare_servers = 3 | ||
EOT; | ||
|
||
// php-fpm must not be launched with --force-stderr option | ||
$tester = new FPM\Tester($cfg, '', [FPM\Tester::PHP_FPM_DISABLE_FORCE_STDERR => true]); | ||
// getPrefixedFile('err.log') is the same path that returns processTemplate('{{FILE:LOG}}') | ||
$errorLogFile = $tester->getPrefixedFile('err.log'); | ||
|
||
$tester->start(); | ||
$tester->expectNoLogMessages(); | ||
|
||
$content = file_get_contents($errorLogFile); | ||
assert($content !== false && strlen($content) > 0, 'File must not be empty'); | ||
|
||
$errorLogLines = explode("\n", $content); | ||
array_pop($errorLogLines); | ||
|
||
assert(count($errorLogLines) === 2, 'Expected 2 records in the error_log file'); | ||
assert(strpos($errorLogLines[0], 'NOTICE: fpm is running, pid')); | ||
assert(strpos($errorLogLines[1], 'NOTICE: ready to handle connections')); | ||
|
||
$tester->ping('{{ADDR}}'); | ||
$stderrLines = $tester->getLogLines(-1); | ||
assert(count($stderrLines) === 1, 'Expected 1 record in the stderr output (access.log)'); | ||
$stderrLine = $stderrLines[0]; | ||
assert(preg_match('/127.0.0.1 .* "GET \/ping" 200$/', $stderrLine), 'Incorrect format of access.log record'); | ||
|
||
$tester->signal('USR1'); | ||
$tester->expectNoLogMessages(); | ||
|
||
$content = file_get_contents($errorLogFile); | ||
assert($content !== false && strlen($content) > 0, 'File must not be empty'); | ||
$errorLogLines = explode("\n", $content); | ||
array_pop($errorLogLines); | ||
|
||
assert(count($errorLogLines) >= 4, 'Expected at least 4 records in the error_log file'); | ||
assert(strpos($errorLogLines[0], 'NOTICE: fpm is running, pid')); | ||
assert(strpos($errorLogLines[1], 'NOTICE: ready to handle connections')); | ||
assert(strpos($errorLogLines[2], 'NOTICE: error log file re-opened')); | ||
assert(strpos($errorLogLines[3], 'NOTICE: access log file re-opened')); | ||
|
||
|
||
$tester->ping('{{ADDR}}'); | ||
$stderrLines = $tester->getLogLines(-1); | ||
assert(count($stderrLines) === 1, 'Must be only 1 record in the access.log'); | ||
assert(preg_match('/127.0.0.1 .* "GET \/ping" 200$/', $stderrLines[0]), 'Incorrect format of access.log record'); | ||
|
||
$tester->terminate(); | ||
$stderrLines = $tester->expectNoLogMessages(); | ||
|
||
$content = file_get_contents($errorLogFile); | ||
assert($content !== false && strlen($content) > 0, 'File must not be empty'); | ||
$errorLogLines = explode("\n", $content); | ||
array_pop($errorLogLines); | ||
$errorLogLastLine = array_pop($errorLogLines); | ||
assert(strpos($errorLogLastLine, 'NOTICE: exiting, bye-bye')); | ||
|
||
$tester->close(); | ||
?> | ||
Done | ||
--EXPECT-- | ||
Done | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--TEST-- | ||
FPM: bug8885 - access.log with stderr begins to write logs to error_log after daemon reload (GH-8885) | ||
--SKIPIF-- | ||
<?php | ||
include "skipif.inc"; | ||
FPM\Tester::skipIfRoot(); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once "tester.inc"; | ||
|
||
$cfg = <<<EOT | ||
[global] | ||
error_log = {{FILE:LOG}} | ||
pid = {{FILE:PID}} | ||
[unconfined] | ||
listen = {{ADDR}} | ||
access.log=/proc/self/fd/2 | ||
ping.path = /ping | ||
ping.response = pong | ||
pm = dynamic | ||
pm.max_children = 5 | ||
pm.start_servers = 1 | ||
pm.min_spare_servers = 1 | ||
pm.max_spare_servers = 3 | ||
EOT; | ||
|
||
// php-fpm must not be launched with --force-stderr option | ||
$tester = new FPM\Tester($cfg, '', [FPM\Tester::PHP_FPM_DISABLE_FORCE_STDERR => true]); | ||
// getPrefixedFile('err.log') is the same path that returns processTemplate('{{FILE:LOG}}') | ||
$errorLogFile = $tester->getPrefixedFile('err.log'); | ||
|
||
$tester->start(); | ||
$tester->expectNoLogMessages(); | ||
|
||
$content = file_get_contents($errorLogFile); | ||
assert($content !== false && strlen($content) > 0, 'File must not be empty'); | ||
|
||
$errorLogLines = explode("\n", $content); | ||
array_pop($errorLogLines); | ||
|
||
assert(count($errorLogLines) === 2, 'Expected 2 records in the error_log file'); | ||
assert(strpos($errorLogLines[0], 'NOTICE: fpm is running, pid')); | ||
assert(strpos($errorLogLines[1], 'NOTICE: ready to handle connections')); | ||
|
||
$tester->ping('{{ADDR}}'); | ||
$stderrLines = $tester->getLogLines(-1); | ||
assert(count($stderrLines) === 1, 'Expected 1 record in the stderr output (access.log)'); | ||
$stderrLine = $stderrLines[0]; | ||
assert(preg_match('/127.0.0.1 .* "GET \/ping" 200$/', $stderrLine), 'Incorrect format of access.log record'); | ||
|
||
$tester->signal('USR2'); | ||
$tester->expectLogNotice('using inherited socket fd=\d+, "127.0.0.1:\d+"'); | ||
|
||
$content = file_get_contents($errorLogFile); | ||
assert($content !== false && strlen($content) > 0, 'File must not be empty'); | ||
$errorLogLines = explode("\n", $content); | ||
array_pop($errorLogLines); | ||
|
||
assert(count($errorLogLines) >= 5, 'Expected at least 5 records in the error_log file'); | ||
assert(strpos($errorLogLines[0], 'NOTICE: fpm is running, pid')); | ||
assert(strpos($errorLogLines[1], 'NOTICE: ready to handle connections')); | ||
assert(strpos($errorLogLines[2], 'NOTICE: Reloading in progress')); | ||
assert(strpos($errorLogLines[3], 'NOTICE: reloading: execvp')); | ||
assert(strpos($errorLogLines[4], 'NOTICE: using inherited socket')); | ||
|
||
$tester->ping('{{ADDR}}'); | ||
$stderrLines = $tester->getLogLines(-1); | ||
assert(count($stderrLines) === 1, 'Must be only 1 record in the access.log'); | ||
assert(preg_match('/127.0.0.1 .* "GET \/ping" 200$/', $stderrLines[0]), 'Incorrect format of access.log record'); | ||
|
||
$tester->terminate(); | ||
$stderrLines = $tester->expectNoLogMessages(); | ||
|
||
$content = file_get_contents($errorLogFile); | ||
assert($content !== false && strlen($content) > 0, 'File must not be empty'); | ||
$errorLogLines = explode("\n", $content); | ||
array_pop($errorLogLines); | ||
$errorLogLastLine = array_pop($errorLogLines); | ||
assert(strpos($errorLogLastLine, 'NOTICE: exiting, bye-bye')); | ||
|
||
$tester->close(); | ||
?> | ||
Done | ||
--EXPECT-- | ||
Done | ||
--CLEAN-- | ||
<?php | ||
require_once "tester.inc"; | ||
FPM\Tester::clean(); | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to get this integrated to the tester and introduce something like
getErrorLogLines
maybe even have something likeexpectErrorLogLines
.