addOption('install', null, InputOption::VALUE_NONE, 'Install missing python deps into .venv') ->addOption('start', null, InputOption::VALUE_NONE, 'Start service if not running') ->addOption('stop', null, InputOption::VALUE_NONE, 'Stop service using PID file') ->addOption('force', null, InputOption::VALUE_NONE, 'Force stop (SIGKILL) if needed') ->addOption('reload', null, InputOption::VALUE_NONE, 'Trigger /reload') ->addOption('status', null, InputOption::VALUE_NONE, 'Print status') ->addOption('foreground', null, InputOption::VALUE_NONE, 'Start in foreground (rare)') ->addOption('port', null, InputOption::VALUE_OPTIONAL, 'Port (default 8090)', '8090') ->addOption('host', null, InputOption::VALUE_OPTIONAL, 'Host (default 0.0.0.0)', '0.0.0.0'); } protected function execute(InputInterface $input, OutputInterface $output): int { $cmd = ['.venv/bin/python', 'python/vector/vector_control.py']; if ($input->getOption('install')) { $cmd[] = '--install'; } if ($input->getOption('start')) { $cmd[] = '--start'; } if ($input->getOption('stop')) { $cmd[] = '--stop'; } if ($input->getOption('force')) { $cmd[] = '--force'; } if ($input->getOption('reload')) { $cmd[] = '--reload'; } if ($input->getOption('status')) { $cmd[] = '--status'; } if ($input->getOption('foreground')) { $cmd[] = '--foreground'; } $cmd[] = '--port'; $cmd[] = (string)$input->getOption('port'); $cmd[] = '--host'; $cmd[] = (string)$input->getOption('host'); $process = new Process($cmd); $process->setTimeout(300); $process->run(); $output->writeln($process->getOutput()); return $process->isSuccessful() ? Command::SUCCESS : Command::FAILURE; } }