Refactor app:init command and update cleanup options

This commit is contained in:
Andras Bacsai 2024-02-08 11:05:31 +01:00
parent 3d7295fec3
commit 7554de5993
2 changed files with 27 additions and 26 deletions

View File

@ -14,24 +14,22 @@ use Illuminate\Support\Facades\Http;
class Init extends Command class Init extends Command
{ {
protected $signature = 'app:init {--cleanup}'; protected $signature = 'app:init {--full-cleanup}';
protected $description = 'Cleanup instance related stuffs'; protected $description = 'Cleanup instance related stuffs';
public function handle() public function handle()
{ {
$this->alive(); $this->alive();
$cleanup = $this->option('cleanup'); $init = $this->option('init');
if ($cleanup) { if ($init) {
echo "Running cleanups...\n"; echo "Running init cleanups.\n";
$this->call('cleanup:stucked-resources');
// Required for falsely deleted coolify db // Required for falsely deleted coolify db
$this->restore_coolify_db_backup(); $this->restore_coolify_db_backup();
// $this->cleanup_ssh();
}
$this->cleanup_in_progress_application_deployments(); $this->cleanup_in_progress_application_deployments();
$this->cleanup_stucked_helper_containers(); $this->cleanup_stucked_helper_containers();
$this->call('cleanup:queue');
$this->call('cleanup:stucked-resources');
try { try {
setup_dynamic_configuration(); setup_dynamic_configuration();
} catch (\Throwable $e) { } catch (\Throwable $e) {
@ -46,7 +44,11 @@ class Init extends Command
$settings->update(['is_auto_update_enabled' => false]); $settings->update(['is_auto_update_enabled' => false]);
} }
} }
$this->call('cleanup:queue'); return;
}
echo "Running cleanups.\n";
$this->cleanup_stucked_helper_containers();
$this->call('cleanup:stucked-resources');
} }
private function restore_coolify_db_backup() private function restore_coolify_db_backup()
{ {
@ -129,5 +131,4 @@ class Init extends Command
echo "Error: {$e->getMessage()}\n"; echo "Error: {$e->getMessage()}\n";
} }
} }
} }

View File

@ -1,3 +1,3 @@
#!/command/execlineb -P #!/command/execlineb -P
s6-setuidgid webuser s6-setuidgid webuser
php /var/www/html/artisan app:init --cleanup php /var/www/html/artisan app:init --full-cleanup