add py control service
This commit is contained in:
51
src/Command/VectorControlCommand.php
Normal file
51
src/Command/VectorControlCommand.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user