-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle child process unexpectedly dying, emit exceptions when that ha…
…ppens, and also when the connection with the child process gets cut off. Run overflow example on CI's to ensure that behavior Closes #14
- Loading branch information
1 parent
a108064
commit afde926
Showing
11 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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,25 @@ | ||
<?php | ||
|
||
require dirname(dirname(__DIR__)) . '/vendor/autoload.php'; | ||
|
||
use React\EventLoop\Factory; | ||
use WyriHaximus\React\ChildProcess\Messenger\Factory as MessengerFactory; | ||
use WyriHaximus\React\ChildProcess\Messenger\Messages\Factory as MessageFactory; | ||
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload; | ||
use WyriHaximus\React\ChildProcess\Messenger\Messenger; | ||
|
||
$loop = Factory::create(); | ||
|
||
MessengerFactory::parentFromClass(ExamplesChildProcess::class, $loop)->then(function (Messenger $messenger) { | ||
return $messenger->rpc( | ||
MessageFactory::rpc('overflow') | ||
)->always(function () use ($messenger) { | ||
$messenger->softTerminate(); | ||
}); | ||
})->done(function (Payload $result) { | ||
throw new Exception('Should never reach this!'); | ||
}, function ($et) { | ||
echo (string)$et; | ||
}); | ||
|
||
$loop->run(); |
This file contains 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,13 @@ | ||
<?php | ||
|
||
namespace WyriHaximus\React\ChildProcess\Messenger; | ||
|
||
use Exception; | ||
|
||
final class CommunicationWithProcessUnexpectedEndException extends Exception | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct('Communication with process stopped unexpectedly'); | ||
} | ||
} |
This file contains 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 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 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 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,16 @@ | ||
<?php | ||
|
||
namespace WyriHaximus\React\ChildProcess\Messenger; | ||
|
||
use Exception; | ||
|
||
final class ProcessUnexpectedEndException extends Exception | ||
{ | ||
/** | ||
* @param int $exitCode | ||
*/ | ||
public function __construct($exitCode) | ||
{ | ||
parent::__construct('Process stopped unexpectedly', $exitCode); | ||
} | ||
} |
This file contains 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 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