update init script
This commit is contained in:
		@@ -7,6 +7,7 @@ use App\Models\Application;
 | 
			
		||||
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 @@ class Init extends Command
 | 
			
		||||
        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,7 +55,8 @@ class Init extends Command
 | 
			
		||||
            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();
 | 
			
		||||
@@ -100,6 +103,28 @@ class Init extends Command
 | 
			
		||||
                    $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) {
 | 
			
		||||
                if (!$service->environment) {
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ return [
 | 
			
		||||
 | 
			
		||||
    // 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'),
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,3 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
return '4.0.0-beta.102';
 | 
			
		||||
return '4.0.0-beta.103';
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
            "version": "3.12.36"
 | 
			
		||||
        },
 | 
			
		||||
        "v4": {
 | 
			
		||||
            "version": "4.0.0-beta.102"
 | 
			
		||||
            "version": "4.0.0-beta.103"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user