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:
Frank
2026-09-12 13:57:00 +02:00
co-authored by Claude Sonnet 5
parent 9ba4197bfd
commit bc0433e356
+9
View File
@@ -66,6 +66,15 @@ final class PuzzleRelayCommand extends Command
Worker::$logFile = $logDir.'/puzzle-relay.log';
Worker::$pidFile = $logDir.'/puzzle-relay.pid';
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->onConnect = static function (TcpConnection $connection): void {