Fix puzzle-relay exiting immediately on Linux: force start command
Worker::runAll() parses start/stop/restart/... off the real \$argv on Linux - which here is Symfony console's own arguments (bin/console app:puzzle-relay), not a command it recognizes, so it printed its usage text and exited on every boot, and Docker kept restarting it forever. Windows skips that argv parsing entirely, which is why this never showed up locally. Worker::\$command = 'start' is Workerman's own mechanism for exactly this "used as a library" case - it appends to what getArgv() returns without touching the real \$argv. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -66,6 +66,15 @@ final class PuzzleRelayCommand extends Command
|
|||||||
Worker::$logFile = $logDir.'/puzzle-relay.log';
|
Worker::$logFile = $logDir.'/puzzle-relay.log';
|
||||||
Worker::$pidFile = $logDir.'/puzzle-relay.pid';
|
Worker::$pidFile = $logDir.'/puzzle-relay.pid';
|
||||||
Worker::$stdoutFile = $logDir.'/puzzle-relay-stdout.log';
|
Worker::$stdoutFile = $logDir.'/puzzle-relay-stdout.log';
|
||||||
|
// On Linux, Worker::runAll() parses start/stop/restart/... off the
|
||||||
|
// real $argv - which here holds Symfony console's own arguments
|
||||||
|
// (bin/console app:puzzle-relay), not a command it recognizes, so it
|
||||||
|
// printed its usage text and exited immediately. This is Workerman's
|
||||||
|
// own escape hatch for exactly that: getArgv() appends $command's
|
||||||
|
// words to $argv before parsing, without touching $argv itself.
|
||||||
|
// (Windows skips this argv parsing entirely, which is why local dev
|
||||||
|
// never hit it.)
|
||||||
|
Worker::$command = 'start';
|
||||||
|
|
||||||
$worker = new Worker("websocket://{$this->listenAddress}");
|
$worker = new Worker("websocket://{$this->listenAddress}");
|
||||||
$worker->onConnect = static function (TcpConnection $connection): void {
|
$worker->onConnect = static function (TcpConnection $connection): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user