refactor new deployment job
This commit is contained in:
parent
a8e9ee2e95
commit
df2bcdb854
@ -5,6 +5,7 @@ namespace App\Actions\CoolifyTask;
|
|||||||
use App\Enums\ActivityTypes;
|
use App\Enums\ActivityTypes;
|
||||||
use App\Enums\ProcessStatus;
|
use App\Enums\ProcessStatus;
|
||||||
use App\Jobs\ApplicationDeploymentJob;
|
use App\Jobs\ApplicationDeploymentJob;
|
||||||
|
use App\Jobs\ApplicationDeploymentJobNew;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Process\ProcessResult;
|
use Illuminate\Process\ProcessResult;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@ -165,7 +166,15 @@ class RunRemoteProcess
|
|||||||
public function encodeOutput($type, $output)
|
public function encodeOutput($type, $output)
|
||||||
{
|
{
|
||||||
$outputStack = json_decode($this->activity->description, associative: true, flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
|
$outputStack = json_decode($this->activity->description, associative: true, flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
|
||||||
|
if (isDev()) {
|
||||||
|
$outputStack[] = [
|
||||||
|
'type' => $type,
|
||||||
|
'output' => $output,
|
||||||
|
'timestamp' => hrtime(true),
|
||||||
|
'batch' => ApplicationDeploymentJobNew::$batch_counter,
|
||||||
|
'order' => $this->getLatestCounter(),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
$outputStack[] = [
|
$outputStack[] = [
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'output' => $output,
|
'output' => $output,
|
||||||
@ -173,6 +182,7 @@ class RunRemoteProcess
|
|||||||
'batch' => ApplicationDeploymentJob::$batch_counter,
|
'batch' => ApplicationDeploymentJob::$batch_counter,
|
||||||
'order' => $this->getLatestCounter(),
|
'order' => $this->getLatestCounter(),
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return json_encode($outputStack, flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
|
return json_encode($outputStack, flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
|
2154
app/Jobs/ApplicationDeploymentJobNew.php
Normal file
2154
app/Jobs/ApplicationDeploymentJobNew.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use App\Enums\ApplicationDeploymentStatus;
|
use App\Enums\ApplicationDeploymentStatus;
|
||||||
use App\Jobs\ApplicationDeploymentJob;
|
use App\Jobs\ApplicationDeploymentJob;
|
||||||
|
use App\Jobs\ApplicationDeploymentJobNew;
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\ApplicationDeploymentQueue;
|
use App\Models\ApplicationDeploymentQueue;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
@ -42,6 +43,17 @@ function queue_application_deployment(Application $application, string $deployme
|
|||||||
'only_this_server' => $only_this_server
|
'only_this_server' => $only_this_server
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (isDev()) {
|
||||||
|
if ($no_questions_asked) {
|
||||||
|
dispatch(new ApplicationDeploymentJobNew(
|
||||||
|
application_deployment_queue_id: $deployment->id,
|
||||||
|
));
|
||||||
|
} else if (next_queuable($server_id, $application_id)) {
|
||||||
|
dispatch(new ApplicationDeploymentJobNew(
|
||||||
|
application_deployment_queue_id: $deployment->id,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if ($no_questions_asked) {
|
if ($no_questions_asked) {
|
||||||
dispatch(new ApplicationDeploymentJob(
|
dispatch(new ApplicationDeploymentJob(
|
||||||
application_deployment_queue_id: $deployment->id,
|
application_deployment_queue_id: $deployment->id,
|
||||||
@ -52,15 +64,22 @@ function queue_application_deployment(Application $application, string $deployme
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function force_start_deployment(ApplicationDeploymentQueue $deployment)
|
function force_start_deployment(ApplicationDeploymentQueue $deployment)
|
||||||
{
|
{
|
||||||
$deployment->update([
|
$deployment->update([
|
||||||
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
||||||
]);
|
]);
|
||||||
|
if (isDev()) {
|
||||||
|
dispatch(new ApplicationDeploymentJobNew(
|
||||||
|
application_deployment_queue_id: $deployment->id,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
dispatch(new ApplicationDeploymentJob(
|
dispatch(new ApplicationDeploymentJob(
|
||||||
application_deployment_queue_id: $deployment->id,
|
application_deployment_queue_id: $deployment->id,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function queue_next_deployment(Application $application)
|
function queue_next_deployment(Application $application)
|
||||||
{
|
{
|
||||||
$server_id = $application->destination->server_id;
|
$server_id = $application->destination->server_id;
|
||||||
@ -69,11 +88,17 @@ function queue_next_deployment(Application $application)
|
|||||||
$next_found->update([
|
$next_found->update([
|
||||||
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
||||||
]);
|
]);
|
||||||
|
if (isDev()) {
|
||||||
|
dispatch(new ApplicationDeploymentJobNew(
|
||||||
|
application_deployment_queue_id: $next_found->id,
|
||||||
|
));
|
||||||
|
} else {
|
||||||
dispatch(new ApplicationDeploymentJob(
|
dispatch(new ApplicationDeploymentJob(
|
||||||
application_deployment_queue_id: $next_found->id,
|
application_deployment_queue_id: $next_found->id,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function next_queuable(string $server_id, string $application_id): bool
|
function next_queuable(string $server_id, string $application_id): bool
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user