File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+
3
+ use ApiClients \Client \Supervisord \AsyncClient ;
4
+ use ApiClients \Client \Supervisord \Resource \Async \Program ;
5
+ use React \EventLoop \Factory ;
6
+ use function ApiClients \Foundation \resource_pretty_print ;
7
+
8
+ require dirname (__DIR__ ) . DIRECTORY_SEPARATOR . 'vendor/autoload.php ' ;
9
+
10
+ $ loop = Factory::create ();
11
+ $ client = AsyncClient::create (require __DIR__ . DIRECTORY_SEPARATOR . 'resolve_host.php ' , $ loop );
12
+
13
+ $ client ->programs ()->take (1 )->subscribe (function (Program $ program ) {
14
+ resource_pretty_print ($ program );
15
+ $ program ->restart ()->done (function (Program $ program ) {
16
+ resource_pretty_print ($ program );
17
+ });
18
+ }, function ($ et ) {
19
+ echo (string )$ et ;
20
+ });
21
+
22
+ $ loop ->run ();
Original file line number Diff line number Diff line change @@ -30,4 +30,13 @@ public function disable(): PromiseInterface
30
30
{
31
31
return $ this ->handleCommand (new StopCommand ($ this ->name ));
32
32
}
33
+
34
+ public function restart (): PromiseInterface
35
+ {
36
+ return $ this ->disable ()->then (function () {
37
+ return $ this ->enable ();
38
+ })->then (function () {
39
+ return $ this ->refresh ();
40
+ });
41
+ }
33
42
}
You can’t perform that action at this time.
0 commit comments