Right now if you start wrench server as $server->run() it launches an indefinite loop (while(true)). Only one way to stop it - kill the process.
What about to add user possibility to control it?
For example, I can write my own function, which listens process's signals or checks existing of some file. I want to pass this function to run() and stop looping when my function returns false.
For compatibility it could look like:
public function run(callable $finish = null)
{
...
if (!is_callable($finish) ) {
$finish = function() { return true; };
}
while ( $finish() ) {
...
}
}
Of course, I can create my own Server class (which extends main class) and redefine function run(). But I'm not sure, that it will be more correctly, than add native support.
@dominics what do you think? I would like to ask before making PR.
Right now if you start wrench server as
$server->run()
it launches an indefinite loop (while(true)
). Only one way to stop it - kill the process. What about to add user possibility to control it? For example, I can write my own function, which listens process's signals or checks existing of some file. I want to pass this function torun()
and stop looping when my function returns false. For compatibility it could look like:Of course, I can create my own Server class (which extends main class) and redefine function run(). But I'm not sure, that it will be more correctly, than add native support. @dominics what do you think? I would like to ask before making PR.