From 397f5ebadd956addb29b71d14c4d370a34b18ced Mon Sep 17 00:00:00 2001 From: Netkas Date: Thu, 9 Feb 2023 18:08:38 -0500 Subject: [PATCH] Added Monitor Mode --- src/TamerLib/Tamer.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/TamerLib/Tamer.php b/src/TamerLib/Tamer.php index a9b2d0c..9f9c9b3 100644 --- a/src/TamerLib/Tamer.php +++ b/src/TamerLib/Tamer.php @@ -311,6 +311,25 @@ } } + /** + * Monitors the workers and restarts them if they die unexpectedly (monitor mode only) + * + * @param bool $auto_restart + * @return void + * @throws Exception + */ + public static function monitor(bool $auto_restart=false): void + { + if (self::$mode === Mode::Client) + { + self::$supervisor->monitor($auto_restart); + } + else + { + throw new InvalidArgumentException('Tamer is not running in client mode'); + } + } + /** * Adds a worker to the supervisor *