add py control service

This commit is contained in:
team2
2026-02-22 08:42:28 +01:00
parent 2629774dcd
commit 4dfed5a797
2 changed files with 180 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(
name: 'mto:agent:vector:control',
description: 'Vector environment control'
)]
final class VectorControlCommand extends Command
{
protected function configure(): void
{
$this
->addOption('install', null, InputOption::VALUE_NONE)
->addOption('start', null, InputOption::VALUE_NONE)
->addOption('reload', null, InputOption::VALUE_NONE);
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$cmd = ['.venv/bin/python', 'src/Vector/vector_control.py'];
if ($input->getOption('install')) {
$cmd[] = '--install';
}
if ($input->getOption('start')) {
$cmd[] = '--start';
}
if ($input->getOption('reload')) {
$cmd[] = '--reload';
}
$process = new \Symfony\Component\Process\Process($cmd);
$process->setTimeout(300);
$process->run();
$output->writeln($process->getOutput());
return Command::SUCCESS;
}
}