-
Notifications
You must be signed in to change notification settings - Fork 4
Send output of maintenance/update.php to stdout #348
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
base: main
Are you sure you want to change the base?
Conversation
array_push( $out, $line ); | ||
} | ||
|
||
while( $line = fgets( $stderrProc ) ) { |
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's a little unclear to me if this means that we end up batching up all the internal stdout lines and output each of those to the main stdout (and also store in $out
) before only then addressing the stderr batch.
e.g. if we have a command that runs for an hour and the first thing to happen is something on STDERR would we see nothing at all until STDOUT has got to the end of the stream. I suspect we might find this a little misleading if it's the case.
My attempts to test this but putting something like:
$stdout = fopen( 'php://stderr', 'w');
fwrite( $stdout, “hello, world\n”);
fclose($stdout);
in update.php
simply resulted in having no output of at all from the inner script
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.
I sadly only can confirm your assumption. I tried to find a way around it but not successfully. For example, I wrapped the two while() loops in a while(proc_get_status( $proc ) )[ 'running' ])
and turned the while($line = fgets( ...
into if
statements. And while that alternates between writing stdout and stderr output, it doesn't make sure that you get everything in the right order and (even worse) that you get every line at all.
$mwPath = realpath( __DIR__ . '/../../../' ); | ||
$cmd = 'WBS_DOMAIN=' . $GLOBALS[WBSTACK_INFO_GLOBAL]->requestDomain . ' php ' . $mwPath . '/maintenance/update.php --quick'; | ||
exec($cmd, $out, $return); | ||
$cmd = 'WBS_DOMAIN=' . $domain . ' php ' . $mwPath . '/maintenance/update.php --quick'; |
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.
I think it might be worth trying if we can have the command itself redirect stderr to stdout like this:
$cmd = 'WBS_DOMAIN=' . $domain . ' php ' . $mwPath . '/maintenance/update.php --quick 2>&1';
which in case it does work could save us a few hoops to jump through in here.
No description provided.