LegacyDeploymentApi: Call activation tool to deploy a new stage
refs #13049
This commit is contained in:
parent
37f3d1a3e8
commit
660f41f94d
|
@ -17,11 +17,14 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
||||||
{
|
{
|
||||||
protected $db;
|
protected $db;
|
||||||
protected $deploymentPath;
|
protected $deploymentPath;
|
||||||
|
protected $activationScript;
|
||||||
|
|
||||||
public function __construct(Db $db)
|
public function __construct(Db $db)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->deploymentPath = $this->db->settings()->deployment_path_v1;
|
$settings = $this->db->settings();
|
||||||
|
$this->deploymentPath = $settings->deployment_path_v1;
|
||||||
|
$this->activationScript = $settings->activation_script_v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,9 +210,13 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$succeeded = $this->deployStage($stage_name, $config->getFileContents());
|
$succeeded = $this->deployStage($stage_name, $config->getFileContents());
|
||||||
# TODO: call deployment tool
|
if ($succeeded === true) {
|
||||||
|
$succeeded = $this->activateStage($stage_name);
|
||||||
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$deployment->set('dump_succeeded', 'n');
|
$deployment->set('dump_succeeded', 'n');
|
||||||
|
$deployment->set('startup_log', $e->getMessage());
|
||||||
|
$deployment->set('startup_succeeded', 'n');
|
||||||
$deployment->store($db);
|
$deployment->store($db);
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
@ -271,6 +278,36 @@ class LegacyDeploymentApi implements DeploymentApiInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts activation of
|
||||||
|
*
|
||||||
|
* Note: script should probably fork to background?
|
||||||
|
*
|
||||||
|
* @param string $stage Stage to activate
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @throws IcingaException For an execution error
|
||||||
|
*/
|
||||||
|
protected function activateStage($stage)
|
||||||
|
{
|
||||||
|
if ($this->activationScript === null || trim($this->activationScript === null) === '') {
|
||||||
|
// skip activation, could be done by external cron worker
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$command = sprintf('%s %s 2>&1', escapeshellcmd($this->activationScript), escapeshellarg($stage));
|
||||||
|
$output = null;
|
||||||
|
$rc = null;
|
||||||
|
exec($command, $output, $rc);
|
||||||
|
$output = join("\n", $output);
|
||||||
|
if ($rc !== 0) {
|
||||||
|
throw new IcingaException("Activation script did exit with return code %d:\n\n%s", $rc, $output);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively dump directory contents, with relative path
|
* Recursively dump directory contents, with relative path
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue