refactor new deployment job
This commit is contained in:
parent
a8e9ee2e95
commit
df2bcdb854
@ -5,6 +5,7 @@
|
||||
use App\Enums\ActivityTypes;
|
||||
use App\Enums\ProcessStatus;
|
||||
use App\Jobs\ApplicationDeploymentJob;
|
||||
use App\Jobs\ApplicationDeploymentJobNew;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Process\ProcessResult;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -165,14 +166,23 @@ protected function elapsedTime(): int
|
||||
public function encodeOutput($type, $output)
|
||||
{
|
||||
$outputStack = json_decode($this->activity->description, associative: true, flags: JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$outputStack[] = [
|
||||
'type' => $type,
|
||||
'output' => $output,
|
||||
'timestamp' => hrtime(true),
|
||||
'batch' => ApplicationDeploymentJob::$batch_counter,
|
||||
'order' => $this->getLatestCounter(),
|
||||
];
|
||||
if (isDev()) {
|
||||
$outputStack[] = [
|
||||
'type' => $type,
|
||||
'output' => $output,
|
||||
'timestamp' => hrtime(true),
|
||||
'batch' => ApplicationDeploymentJobNew::$batch_counter,
|
||||
'order' => $this->getLatestCounter(),
|
||||
];
|
||||
} else {
|
||||
$outputStack[] = [
|
||||
'type' => $type,
|
||||
'output' => $output,
|
||||
'timestamp' => hrtime(true),
|
||||
'batch' => ApplicationDeploymentJob::$batch_counter,
|
||||
'order' => $this->getLatestCounter(),
|
||||
];
|
||||
}
|
||||
|
||||
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\Jobs\ApplicationDeploymentJob;
|
||||
use App\Jobs\ApplicationDeploymentJobNew;
|
||||
use App\Models\Application;
|
||||
use App\Models\ApplicationDeploymentQueue;
|
||||
use App\Models\Server;
|
||||
@ -42,14 +43,26 @@ function queue_application_deployment(Application $application, string $deployme
|
||||
'only_this_server' => $only_this_server
|
||||
]);
|
||||
|
||||
if ($no_questions_asked) {
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $deployment->id,
|
||||
));
|
||||
} else if (next_queuable($server_id, $application_id)) {
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $deployment->id,
|
||||
));
|
||||
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) {
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $deployment->id,
|
||||
));
|
||||
} else if (next_queuable($server_id, $application_id)) {
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $deployment->id,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
function force_start_deployment(ApplicationDeploymentQueue $deployment)
|
||||
@ -57,9 +70,15 @@ function force_start_deployment(ApplicationDeploymentQueue $deployment)
|
||||
$deployment->update([
|
||||
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
||||
]);
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $deployment->id,
|
||||
));
|
||||
if (isDev()) {
|
||||
dispatch(new ApplicationDeploymentJobNew(
|
||||
application_deployment_queue_id: $deployment->id,
|
||||
));
|
||||
} else {
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $deployment->id,
|
||||
));
|
||||
}
|
||||
}
|
||||
function queue_next_deployment(Application $application)
|
||||
{
|
||||
@ -69,9 +88,15 @@ function queue_next_deployment(Application $application)
|
||||
$next_found->update([
|
||||
'status' => ApplicationDeploymentStatus::IN_PROGRESS->value,
|
||||
]);
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $next_found->id,
|
||||
));
|
||||
if (isDev()) {
|
||||
dispatch(new ApplicationDeploymentJobNew(
|
||||
application_deployment_queue_id: $next_found->id,
|
||||
));
|
||||
} else {
|
||||
dispatch(new ApplicationDeploymentJob(
|
||||
application_deployment_queue_id: $next_found->id,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user