fix: deployment queue

fix: cancel deployment
ui: changed to simpler toaster
This commit is contained in:
Andras Bacsai
2024-01-25 11:57:47 +01:00
parent 0c5e8600bd
commit 7a7157c155
10 changed files with 499 additions and 113 deletions

View File

@@ -10,6 +10,9 @@ use Symfony\Component\Yaml\Yaml;
function queue_application_deployment(int $application_id, int $server_id, string $deployment_uuid, int | null $pull_request_id = 0, string $commit = 'HEAD', bool $force_rebuild = false, bool $is_webhook = false, bool $restart_only = false, ?string $git_type = null, bool $is_new_deployment = false)
{
$server = Application::find($application_id)->destination->server;
$deployments_per_server = ApplicationDeploymentQueue::where('server_id', $server_id)->where('status', 'queued')->orWhere('status', 'in_progress')->get();
$deployment = ApplicationDeploymentQueue::create([
'application_id' => $application_id,
'server_id' => $server_id,
@@ -21,14 +24,12 @@ function queue_application_deployment(int $application_id, int $server_id, strin
'commit' => $commit,
'git_type' => $git_type
]);
$server = Application::find($application_id)->destination->server;
$deployments = ApplicationDeploymentQueue::where('application_id', $application_id);
$queued_deployments = $deployments->where('status', 'queued')->get()->sortByDesc('created_at');
$running_deployments = $deployments->where('status', 'in_progress')->get()->sortByDesc('created_at');
$deployments_per_server = ApplicationDeploymentQueue::where('server_id', $server_id)->where('status', 'queued')->orWhere('status', 'in_progress')->get();
ray($deployments_per_server->count(), $server->settings->concurrent_builds);
ray('Q:' . $queued_deployments->count() . 'R:' . $running_deployments->count() . '| Queuing deployment: ' . $deployment_uuid . ' of applicationID: ' . $application_id . ' pull request: ' . $pull_request_id . ' with commit: ' . $commit . ' and is it forced: ' . $force_rebuild);
if ($queued_deployments->count() > 1) {
@@ -58,8 +59,7 @@ function queue_application_deployment(int $application_id, int $server_id, strin
function queue_next_deployment(Application $application, bool $isNew = false)
{
$next_found = ApplicationDeploymentQueue::where('status', 'queued')->get()->sortByDesc('created_at')->first();
ray('Next found: ' . $next_found);
$next_found = ApplicationDeploymentQueue::where('status', 'queued')->get()->sortBy('created_at')->first();
if ($next_found) {
if ($isNew) {
dispatch(new ApplicationDeploymentNewJob(