Skip to content

Commit

Permalink
finally use of uploaded files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Dec 25, 2024
1 parent 8d55dc5 commit caf3925
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/MultiFlexi/Executor/Native.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Native extends \MultiFlexi\CommonExecutor implements \MultiFlexi\executor
{
public $timeout = 32767;
private \Symfony\Component\Process\Process $process;
private $commandline;
private string $commandline;
private array $jobFiles = [];

public static function name(): string
{
Expand All @@ -38,6 +39,13 @@ public static function description(): string
return _('Run Job on same machine as MultiFlexi itself');
}

public function setJob(\MultiFlexi\Job &$job): void {
parent::setJob($job);
$this->jobFiles = (new \MultiFlexi\FileStore())->extractFilesForJob($this->job);

$this->environment = array_merge($this->environment, $this->jobFiles);
}

/**
* @return string
*/
Expand All @@ -56,15 +64,12 @@ public function cmdparams()

public function commandline(): string
{
$this->job->setEnvironment($this->environment);
return $this->executable().' '.$this->cmdparams();
}

public function launch($command)
{
$jobFiles = (new \MultiFlexi\FileStore())->extractFilesForJob($this->job);

$this->environment = array_merge($this->environment, $jobFiles);

$this->process = new \Symfony\Component\Process\Process(explode(' ', $command), null, \MultiFlexi\Environmentor::flatEnv($this->environment), null, $this->timeout);

try {
Expand Down Expand Up @@ -93,7 +98,7 @@ public function launch($command)

$this->addStatusMessage('pid:'.(isset($this->pid) ? (string) ($this->pid) : 'n/a').' '.$command.': '.$this->process->getExitCodeText(), $this->process->getExitCode() === 0 ? 'success' : 'warning');

foreach ($jobFiles as $field => $file) {
foreach ($this->jobFiles as $field => $file) {
unlink($file['value']);
}

Expand Down
4 changes: 4 additions & 0 deletions src/MultiFlexi/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -763,4 +763,8 @@ public function setPid(int $pid): void
$this->setDataValue('pid', $pid);
$this->setZabbixValue('pid', $pid);
}

public function setEnvironment(array $environment) {
$this->environment = $environment;
}
}

0 comments on commit caf3925

Please sign in to comment.