From 071d892c5924e17449b3da04288400f9eb9d1dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 16 Apr 2021 11:39:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Snowflake.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/System/Snowflake.php b/System/Snowflake.php index 32f63c94..55c1ec5f 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -207,7 +207,13 @@ class Snowflake */ public static function setManagerId($workerId): mixed { - return self::writeFile(storage($workerId . '.sock', 'pid/manager'), $workerId); + if (empty($workerId) || static::isDcoker()) { + return $workerId; + } + + $tmpFile = storage($workerId . '.sock', 'pid/manager'); + + return self::writeFile($tmpFile, $workerId); } @@ -218,7 +224,13 @@ class Snowflake */ public static function setProcessId($workerId): mixed { - return self::writeFile(storage($workerId . '.sock', 'pid/process'), $workerId); + if (empty($workerId) || static::isDcoker()) { + return $workerId; + } + + $tmpFile = storage($workerId . '.sock', 'pid/process'); + + return self::writeFile($tmpFile, $workerId); } @@ -259,10 +271,13 @@ class Snowflake */ public static function setTaskId($workerId): mixed { - if (empty($workerId)) { + if (empty($workerId) || static::isDcoker()) { return $workerId; } - return self::writeFile(storage($workerId . '.sock', 'pid/task'), $workerId); + + $tmpFile = storage($workerId . '.sock', 'pid/task'); + + return self::writeFile($tmpFile, $workerId); } /**