改名
This commit is contained in:
@@ -47,10 +47,10 @@ class Shutdown extends Component
|
|||||||
public function shutdown(): void
|
public function shutdown(): void
|
||||||
{
|
{
|
||||||
clearstatcache(storage());
|
clearstatcache(storage());
|
||||||
// exec('ls -alh /.dockerenv', $output, $cod);
|
exec('ls -alh /.dockerenv', $output, $cod);
|
||||||
// if ($cod === 0 && !empty($output)) {
|
if ($cod === 0 && !empty($output)) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
$master_pid = Server()->setting['pid_file'] ?? PID_PATH;
|
$master_pid = Server()->setting['pid_file'] ?? PID_PATH;
|
||||||
if (file_exists($master_pid)) {
|
if (file_exists($master_pid)) {
|
||||||
|
|||||||
+18
-4
@@ -10,7 +10,6 @@ use Database\ActiveRecord;
|
|||||||
use Database\Collection;
|
use Database\Collection;
|
||||||
use Exception;
|
use Exception;
|
||||||
use HttpServer\IInterface\Task;
|
use HttpServer\IInterface\Task;
|
||||||
|
|
||||||
use JetBrains\PhpStorm\Pure;
|
use JetBrains\PhpStorm\Pure;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Snowflake\Abstracts\Config;
|
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
|
* @param $workerId
|
||||||
* @return mixed
|
* @return mixed
|
||||||
@@ -230,10 +242,13 @@ class Snowflake
|
|||||||
*/
|
*/
|
||||||
public static function setWorkerId($workerId): mixed
|
public static function setWorkerId($workerId): mixed
|
||||||
{
|
{
|
||||||
if (empty($workerId)) {
|
if (empty($workerId) || static::isDcoker()) {
|
||||||
return $workerId;
|
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
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user