Skip to content

Commit

Permalink
Check that the source has been defined before trying to execute it
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasnetau committed Feb 27, 2024
1 parent 531e001 commit fbe0d68
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -940,15 +940,19 @@ public function run() : void

/** Handle request to run an on demand source */
$this->engine->on('source', function(Scheduler\Messages\ExecuteSource $execute) {
$config = $this->input_processes_config[$execute->getCmd()];
$rndid = $execute->getCmd() . '_' . bin2hex(random_bytes(4)); //Generate unique ID for the on demand run
$env = ($config['env'] ?? []) + $execute->getVars();
//Register the on demand source
$this->register_input_process($rndid, $config['cmd'], $config['wd'], $env, false, false);
$process = $this->initialise_input_process($rndid);
$process->on('exit', function() use ($rndid) {
$this->unregister_input_process($rndid); //Remove config once process exits
});
if (isset($this->input_processes_config[$execute->getCmd()])) {
$config = $this->input_processes_config[$execute->getCmd()];
$rndid = $execute->getCmd() . '_' . bin2hex(random_bytes(4)); //Generate unique ID for the on demand run
$env = ($config['env'] ?? []) + $execute->getVars();
//Register the on demand source
$this->register_input_process($rndid, $config['cmd'], $config['wd'], $env, false, false);
$process = $this->initialise_input_process($rndid);
$process->on('exit', function() use ($rndid) {
$this->unregister_input_process($rndid); //Remove config once process exits
});
} else {
$this->logger->error("Unable to start unknown on demand source " . json_encode($execute->getCmd()));
}
});

/** If we have any errored actions then we replay them and attempt recovery. In normal state we initialise the input processes */
Expand Down

0 comments on commit fbe0d68

Please sign in to comment.