This commit is contained in:
2021-04-16 11:39:29 +08:00
parent 2e8276ca83
commit 071d892c59
+19 -4
View File
@@ -207,7 +207,13 @@ class Snowflake
*/ */
public static function setManagerId($workerId): mixed 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 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 public static function setTaskId($workerId): mixed
{ {
if (empty($workerId)) { if (empty($workerId) || static::isDcoker()) {
return $workerId; return $workerId;
} }
return self::writeFile(storage($workerId . '.sock', 'pid/task'), $workerId);
$tmpFile = storage($workerId . '.sock', 'pid/task');
return self::writeFile($tmpFile, $workerId);
} }
/** /**