Closed mfn closed 2 years ago
What are the removed code from __construct()
doing ?
I understand that using plain text for the output solve the issue, but is it breaking other thing that only php://stdout can do ?
Is the output styling (color, bold, etc ..) still functioning ?
What are the removed code from __construct() doing ?
This line from cakes ConsoleOutput, internally in PHP, leads to calling dup()
on the stdout
fd and this seems to mess up certain beaviour as outlined in https://github.com/kamisama/Cake-Resque/issues/75#issuecomment-64819153
It's a tricky technicality I cannot explain yet.
I understand that using plain text for the output solve the issue, but is it breaking other thing that only php://stdout can do ?
I'm not aware of any breakage. All the code does it avoid fopen
on stdout
. If you look through the ConsoleOutput class, the internal property $this->_output
is only used in the constructor and the _write()
method and my extending class handles this.
Is the output styling (color, bold, etc ..) still functioning ?
Yes, it still works for me.
There's not difference between writing to the stdout
file handle or using echo
. The intention of ConsoleOutput
is to be flexible so that it could either be stdout
, stderr
or a file which isn't otherwise interchangeable with echo
. The new CakeResqueEchoConsoleOutput
class is only suitable for stdout
and thus only this class is passed to the Shell
constructor:
parent::__construct(new CakeResqueEchoConsoleOutput());
Closing, no longer using CakeResque
The original cake ConsoleHandler uses fopen('php://stdout') which deep down uses the C call 'dup' to duplicate stdout. However this can lead to a worker not returning the shell, e.g.
ssh host .../cake CakeResque.CakeResque start --queue test
would hang without this change.
Fixes kamisama/Cake-Resque#75
Using a custom ConsoleHandler which does not open directly
php://stdout
was the only way avoiding thedup()
call causes the hang when trying to instrument starting workers via ssh.