|
@@ -49,7 +49,7 @@ class Worker
|
|
|
*
|
|
*
|
|
|
* @var string
|
|
* @var string
|
|
|
*/
|
|
*/
|
|
|
- public const VERSION = '5.0.0-beta.3';
|
|
|
|
|
|
|
+ public const VERSION = '5.0.0-beta.5';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Status starting.
|
|
* Status starting.
|
|
@@ -647,9 +647,8 @@ class Worker
|
|
|
*/
|
|
*/
|
|
|
protected static function lock(int $flag = LOCK_EX): void
|
|
protected static function lock(int $flag = LOCK_EX): void
|
|
|
{
|
|
{
|
|
|
- global $argv;
|
|
|
|
|
static $fd;
|
|
static $fd;
|
|
|
- if (DIRECTORY_SEPARATOR !== '/' || empty($argv)) {
|
|
|
|
|
|
|
+ if (DIRECTORY_SEPARATOR !== '/') {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
$lockFile = static::$pidFile . '.lock';
|
|
$lockFile = static::$pidFile . '.lock';
|
|
@@ -827,9 +826,7 @@ class Worker
|
|
|
!empty($content) && static::safeEcho($lineLast);
|
|
!empty($content) && static::safeEcho($lineLast);
|
|
|
|
|
|
|
|
if (static::$daemonize) {
|
|
if (static::$daemonize) {
|
|
|
- global $argv;
|
|
|
|
|
- $startFile = $argv[0];
|
|
|
|
|
- static::safeEcho('Input "php ' . $startFile . ' stop" to stop. Start success.' . "\n\n");
|
|
|
|
|
|
|
+ static::safeEcho('Input "php ' . basename(static::$startFile) . ' stop" to stop. Start success.' . "\n\n");
|
|
|
} else {
|
|
} else {
|
|
|
static::safeEcho("Press Ctrl+C to stop. Start success.\n");
|
|
static::safeEcho("Press Ctrl+C to stop. Start success.\n");
|
|
|
}
|
|
}
|
|
@@ -883,14 +880,12 @@ class Worker
|
|
|
*/
|
|
*/
|
|
|
protected static function parseCommand(): void
|
|
protected static function parseCommand(): void
|
|
|
{
|
|
{
|
|
|
- global $argv;
|
|
|
|
|
-
|
|
|
|
|
- if (DIRECTORY_SEPARATOR !== '/' || empty($argv)) {
|
|
|
|
|
|
|
+ if (DIRECTORY_SEPARATOR !== '/') {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Check argv;
|
|
// Check argv;
|
|
|
- $startFile = $argv[0];
|
|
|
|
|
|
|
+ $startFile = basename(static::$startFile);
|
|
|
$usage = "Usage: php yourfile <command> [mode]\nCommands: \nstart\t\tStart worker in DEBUG mode.\n\t\tUse mode -d to start in DAEMON mode.\nstop\t\tStop worker.\n\t\tUse mode -g to stop gracefully.\nrestart\t\tRestart workers.\n\t\tUse mode -d to start in DAEMON mode.\n\t\tUse mode -g to stop gracefully.\nreload\t\tReload codes.\n\t\tUse mode -g to reload gracefully.\nstatus\t\tGet worker status.\n\t\tUse mode -d to show live status.\nconnections\tGet worker connections.\n";
|
|
$usage = "Usage: php yourfile <command> [mode]\nCommands: \nstart\t\tStart worker in DEBUG mode.\n\t\tUse mode -d to start in DAEMON mode.\nstop\t\tStop worker.\n\t\tUse mode -g to stop gracefully.\nrestart\t\tRestart workers.\n\t\tUse mode -d to start in DAEMON mode.\n\t\tUse mode -g to stop gracefully.\nreload\t\tReload codes.\n\t\tUse mode -g to reload gracefully.\nstatus\t\tGet worker status.\n\t\tUse mode -d to show live status.\nconnections\tGet worker connections.\n";
|
|
|
$availableCommands = [
|
|
$availableCommands = [
|
|
|
'start',
|
|
'start',
|
|
@@ -906,9 +901,10 @@ class Worker
|
|
|
];
|
|
];
|
|
|
$command = $mode = '';
|
|
$command = $mode = '';
|
|
|
foreach (static::getArgv() as $value) {
|
|
foreach (static::getArgv() as $value) {
|
|
|
- if (in_array($value, $availableCommands)) {
|
|
|
|
|
|
|
+ if (!$command && in_array($value, $availableCommands)) {
|
|
|
$command = $value;
|
|
$command = $value;
|
|
|
- } elseif (in_array($value, $availableMode)) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!$mode && in_array($value, $availableMode)) {
|
|
|
$mode = $value;
|
|
$mode = $value;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1046,7 +1042,7 @@ class Worker
|
|
|
public static function getArgv(): array
|
|
public static function getArgv(): array
|
|
|
{
|
|
{
|
|
|
global $argv;
|
|
global $argv;
|
|
|
- return isset($argv[1]) ? $argv : (static::$command ? explode(' ', static::$command) : $argv);
|
|
|
|
|
|
|
+ return static::$command ? array_merge($argv, explode(' ', static::$command)) : $argv;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1297,8 +1293,7 @@ class Worker
|
|
|
*/
|
|
*/
|
|
|
protected static function saveMasterPid(): void
|
|
protected static function saveMasterPid(): void
|
|
|
{
|
|
{
|
|
|
- global $argv;
|
|
|
|
|
- if (DIRECTORY_SEPARATOR !== '/' || empty($argv)) {
|
|
|
|
|
|
|
+ if (DIRECTORY_SEPARATOR !== '/') {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|