Created
January 20, 2018 22:52
-
-
Save WyriHaximus/9262cdba6da5e3a49baee7a59f0b05f0 to your computer and use it in GitHub Desktop.
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
<?php | |
use ApiClients\Client\Supervisord\AsyncClientInterface; | |
use ApiClients\Client\Supervisord\Resource\Async\Program; | |
use ApiClients\Client\Supervisord\Resource\ProgramInterface; | |
use Psr\Log\LoggerInterface; | |
use React\EventLoop\LoopInterface; | |
use Rx\React\Promise; | |
Promise::fromObservable( | |
$this->supervisor->programs()->filter(function (ProgramInterface $program) { | |
return $program->name() === getenv('SUPERVISOR_NAME'); | |
})->take(1) | |
)->then(function (Program $program) { | |
$uptime = $program->now() - $program->start(); | |
$this->logger->info('"' . $program->name() . '" has been up and running for ' . $uptime . ' seconds, restarting'); | |
return $program->restart(); | |
})->done(function (Program $program) { | |
$uptime = $program->now() - $program->start(); | |
$this->logger->info('Restarted "' . $program->name() . '" up and running for ' . $uptime . ' seconds'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment