update init script

This commit is contained in:
Andras Bacsai 2023-10-25 11:43:18 +02:00
parent 379f4b9dff
commit 50fc05ab52
4 changed files with 36 additions and 11 deletions

View File

@ -7,6 +7,7 @@
use App\Models\ApplicationDeploymentQueue;
use App\Models\Service;
use App\Models\StandaloneMongodb;
use App\Models\StandaloneMysql;
use App\Models\StandalonePostgresql;
use App\Models\StandaloneRedis;
use Illuminate\Console\Command;
@ -22,10 +23,11 @@ public function handle()
ray()->clearAll();
$this->cleanup_in_progress_application_deployments();
$this->cleanup_stucked_resources();
$this->cleanup_ssh();
// $this->cleanup_ssh();
}
private function cleanup_ssh() {
private function cleanup_ssh()
{
try {
$files = Storage::allFiles('ssh/keys');
foreach ($files as $file) {
@ -53,11 +55,12 @@ private function cleanup_in_progress_application_deployments()
echo "Error: {$e->getMessage()}\n";
}
}
private function cleanup_stucked_resources() {
private function cleanup_stucked_resources()
{
// Cleanup any resources that are not attached to any environment or destination or server
try {
$applications = Application::all();
foreach($applications as $application) {
foreach ($applications as $application) {
if (!$application->environment) {
ray('Application without environment', $application->name);
$application->delete();
@ -68,7 +71,7 @@ private function cleanup_stucked_resources() {
}
}
$postgresqls = StandalonePostgresql::all();
foreach($postgresqls as $postgresql) {
foreach ($postgresqls as $postgresql) {
if (!$postgresql->environment) {
ray('Postgresql without environment', $postgresql->name);
$postgresql->delete();
@ -79,7 +82,7 @@ private function cleanup_stucked_resources() {
}
}
$redis = StandaloneRedis::all();
foreach($redis as $redis) {
foreach ($redis as $redis) {
if (!$redis->environment) {
ray('Redis without environment', $redis->name);
$redis->delete();
@ -90,7 +93,7 @@ private function cleanup_stucked_resources() {
}
}
$mongodbs = StandaloneMongodb::all();
foreach($mongodbs as $mongodb) {
foreach ($mongodbs as $mongodb) {
if (!$mongodb->environment) {
ray('Mongodb without environment', $mongodb->name);
$mongodb->delete();
@ -100,8 +103,30 @@ private function cleanup_stucked_resources() {
$mongodb->delete();
}
}
$mysqls = StandaloneMysql::all();
foreach ($mysqls as $mysql) {
if (!$mysql->environment) {
ray('Mysql without environment', $mysql->name);
$mysql->delete();
}
if (!$mysql->destination()) {
ray('Mysql without destination', $mysql->name);
$mysql->delete();
}
}
$mariadbs = StandaloneMysql::all();
foreach ($mariadbs as $mariadb) {
if (!$mariadb->environment) {
ray('Mariadb without environment', $mariadb->name);
$mariadb->delete();
}
if (!$mariadb->destination()) {
ray('Mariadb without destination', $mariadb->name);
$mariadb->delete();
}
}
$services = Service::all();
foreach($services as $service) {
foreach ($services as $service) {
if (!$service->environment) {
ray('Service without environment', $service->name);
$service->delete();

View File

@ -7,7 +7,7 @@
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
'release' => '4.0.0-beta.102',
'release' => '4.0.0-beta.103',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),

View File

@ -1,3 +1,3 @@
<?php
return '4.0.0-beta.102';
return '4.0.0-beta.103';

View File

@ -4,7 +4,7 @@
"version": "3.12.36"
},
"v4": {
"version": "4.0.0-beta.102"
"version": "4.0.0-beta.103"
}
}
}