wip
This commit is contained in:
commit
026f953961
@ -16,6 +16,8 @@ class RunRemoteProcess
|
|||||||
|
|
||||||
public bool $hideFromOutput;
|
public bool $hideFromOutput;
|
||||||
|
|
||||||
|
public bool $setStatus;
|
||||||
|
|
||||||
protected $timeStart;
|
protected $timeStart;
|
||||||
|
|
||||||
protected $currentTime;
|
protected $currentTime;
|
||||||
@ -31,7 +33,7 @@ class RunRemoteProcess
|
|||||||
/**
|
/**
|
||||||
* Create a new job instance.
|
* Create a new job instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(Activity $activity, bool $hideFromOutput = false)
|
public function __construct(Activity $activity, bool $hideFromOutput = false, bool $setStatus = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($activity->getExtraProperty('type') !== ActivityTypes::REMOTE_PROCESS->value && $activity->getExtraProperty('type') !== ActivityTypes::DEPLOYMENT->value) {
|
if ($activity->getExtraProperty('type') !== ActivityTypes::REMOTE_PROCESS->value && $activity->getExtraProperty('type') !== ActivityTypes::DEPLOYMENT->value) {
|
||||||
@ -40,6 +42,7 @@ public function __construct(Activity $activity, bool $hideFromOutput = false)
|
|||||||
|
|
||||||
$this->activity = $activity;
|
$this->activity = $activity;
|
||||||
$this->hideFromOutput = $hideFromOutput;
|
$this->hideFromOutput = $hideFromOutput;
|
||||||
|
$this->setStatus = $setStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __invoke(): ProcessResult
|
public function __invoke(): ProcessResult
|
||||||
@ -51,17 +54,18 @@ public function __invoke(): ProcessResult
|
|||||||
|
|
||||||
$processResult = Process::run($this->getCommand(), $this->handleOutput(...));
|
$processResult = Process::run($this->getCommand(), $this->handleOutput(...));
|
||||||
|
|
||||||
$status = match ($processResult->exitCode()) {
|
$status = $processResult->exitCode() != 0 ? ProcessStatus::ERROR : ($this->setStatus ? ProcessStatus::FINISHED : null);
|
||||||
0 => ProcessStatus::FINISHED,
|
|
||||||
default => ProcessStatus::ERROR,
|
|
||||||
};
|
|
||||||
|
|
||||||
$this->activity->properties = $this->activity->properties->merge([
|
$this->activity->properties = $this->activity->properties->merge([
|
||||||
'exitCode' => $processResult->exitCode(),
|
'exitCode' => $processResult->exitCode(),
|
||||||
'stdout' => $this->hideFromOutput || $processResult->output(),
|
'stdout' => $this->hideFromOutput || $processResult->output(),
|
||||||
'stderr' => $processResult->errorOutput(),
|
'stderr' => $processResult->errorOutput(),
|
||||||
'status' => $status,
|
|
||||||
]);
|
]);
|
||||||
|
if (isset($status)) {
|
||||||
|
$this->activity->properties = $this->activity->properties->merge([
|
||||||
|
'status' => $status->value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$this->activity->save();
|
$this->activity->save();
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public function polling()
|
|||||||
$this->activity?->refresh();
|
$this->activity?->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data_get($this->activity, 'properties.exitCode') !== null) {
|
if (data_get($this->activity, 'properties.status') == 'finished' || data_get($this->activity, 'properties.status') == 'failed' ) {
|
||||||
$this->isKeepAliveOn = false;
|
$this->isKeepAliveOn = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public function handle(): void
|
|||||||
$this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d"),
|
$this->execute_in_builder("docker compose --project-directory {$this->workdir} up -d"),
|
||||||
"echo 'Done. 🎉'",
|
"echo 'Done. 🎉'",
|
||||||
"docker stop -t 0 {$this->deployment_uuid} >/dev/null"
|
"docker stop -t 0 {$this->deployment_uuid} >/dev/null"
|
||||||
]);
|
], setStatus: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function execute_in_builder(string $command)
|
private function execute_in_builder(string $command)
|
||||||
@ -244,7 +244,7 @@ private function set_labels_for_applications()
|
|||||||
return $labels;
|
return $labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function executeNow(array $command, string $propertyName = null, bool $hideFromOutput = false)
|
private function executeNow(array $command, string $propertyName = null, bool $hideFromOutput = false, $setStatus = false)
|
||||||
{
|
{
|
||||||
$commandText = collect($command)->implode("\n");
|
$commandText = collect($command)->implode("\n");
|
||||||
|
|
||||||
@ -256,6 +256,7 @@ private function executeNow(array $command, string $propertyName = null, bool $h
|
|||||||
$remoteProcess = resolve(RunRemoteProcess::class, [
|
$remoteProcess = resolve(RunRemoteProcess::class, [
|
||||||
'activity' => $this->activity,
|
'activity' => $this->activity,
|
||||||
'hideFromOutput' => $hideFromOutput,
|
'hideFromOutput' => $hideFromOutput,
|
||||||
|
'setStatus' => $setStatus,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($propertyName) {
|
if ($propertyName) {
|
||||||
|
Loading…
Reference in New Issue
Block a user