diff --git a/HttpServer/Shutdown.php b/HttpServer/Shutdown.php index 86bf34fa..cf01d194 100644 --- a/HttpServer/Shutdown.php +++ b/HttpServer/Shutdown.php @@ -47,10 +47,10 @@ class Shutdown extends Component public function shutdown(): void { clearstatcache(storage()); -// exec('ls -alh /.dockerenv', $output, $cod); -// if ($cod === 0 && !empty($output)) { -// return; -// } + exec('ls -alh /.dockerenv', $output, $cod); + if ($cod === 0 && !empty($output)) { + return; + } $master_pid = Server()->setting['pid_file'] ?? PID_PATH; if (file_exists($master_pid)) { diff --git a/System/Snowflake.php b/System/Snowflake.php index e1a0a738..32f63c94 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -10,7 +10,6 @@ use Database\ActiveRecord; use Database\Collection; use Exception; use HttpServer\IInterface\Task; - use JetBrains\PhpStorm\Pure; use ReflectionException; use Snowflake\Abstracts\Config; @@ -223,6 +222,19 @@ class Snowflake } + /** + * @return bool + */ + public static function isDcoker(): bool + { + exec('ls -alh /.dockerenv', $output, $cod); + if ($cod === 0 && !empty($output)) { + return true; + } + return false; + } + + /** * @param $workerId * @return mixed @@ -230,10 +242,13 @@ class Snowflake */ public static function setWorkerId($workerId): mixed { - if (empty($workerId)) { + if (empty($workerId) || static::isDcoker()) { return $workerId; } - return self::writeFile(storage($workerId . '.sock', 'pid/worker'), $workerId); + + $tmpFile = storage($workerId . '.sock', 'pid/worker'); + + return self::writeFile($tmpFile, $workerId); } @@ -504,7 +519,6 @@ class Snowflake } - /** * @return string|null */