From 7554de59933d8b0763389181eae78dcded27acc8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 11:05:31 +0100 Subject: [PATCH] Refactor app:init command and update cleanup options --- app/Console/Commands/Init.php | 51 ++++++++++--------- .../etc/s6-overlay/s6-rc.d/init-script/up | 2 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php index c4dc20988..03236dd99 100644 --- a/app/Console/Commands/Init.php +++ b/app/Console/Commands/Init.php @@ -14,39 +14,41 @@ class Init extends Command { - protected $signature = 'app:init {--cleanup}'; + protected $signature = 'app:init {--full-cleanup}'; protected $description = 'Cleanup instance related stuffs'; public function handle() { $this->alive(); - $cleanup = $this->option('cleanup'); - if ($cleanup) { - echo "Running cleanups...\n"; - $this->call('cleanup:stucked-resources'); + $init = $this->option('init'); + if ($init) { + echo "Running init cleanups.\n"; + // Required for falsely deleted coolify db $this->restore_coolify_db_backup(); - - // $this->cleanup_ssh(); - } - $this->cleanup_in_progress_application_deployments(); - $this->cleanup_stucked_helper_containers(); - - try { - setup_dynamic_configuration(); - } catch (\Throwable $e) { - echo "Could not setup dynamic configuration: {$e->getMessage()}\n"; - } - - $settings = InstanceSettings::get(); - if (!is_null(env('AUTOUPDATE', null))) { - if (env('AUTOUPDATE') == true) { - $settings->update(['is_auto_update_enabled' => true]); - } else { - $settings->update(['is_auto_update_enabled' => false]); + $this->cleanup_in_progress_application_deployments(); + $this->cleanup_stucked_helper_containers(); + $this->call('cleanup:queue'); + $this->call('cleanup:stucked-resources'); + try { + setup_dynamic_configuration(); + } catch (\Throwable $e) { + echo "Could not setup dynamic configuration: {$e->getMessage()}\n"; } + + $settings = InstanceSettings::get(); + if (!is_null(env('AUTOUPDATE', null))) { + if (env('AUTOUPDATE') == true) { + $settings->update(['is_auto_update_enabled' => true]); + } else { + $settings->update(['is_auto_update_enabled' => false]); + } + } + return; } - $this->call('cleanup:queue'); + echo "Running cleanups.\n"; + $this->cleanup_stucked_helper_containers(); + $this->call('cleanup:stucked-resources'); } private function restore_coolify_db_backup() { @@ -129,5 +131,4 @@ private function cleanup_in_progress_application_deployments() echo "Error: {$e->getMessage()}\n"; } } - } diff --git a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up index b563c067f..ea960df95 100644 --- a/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up +++ b/docker/prod-ssu/etc/s6-overlay/s6-rc.d/init-script/up @@ -1,3 +1,3 @@ #!/command/execlineb -P s6-setuidgid webuser -php /var/www/html/artisan app:init --cleanup +php /var/www/html/artisan app:init --full-cleanup