改名
This commit is contained in:
@@ -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)) {
|
||||
|
||||
+18
-4
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user