refactor: upgrade process of Coolify
This commit is contained in:
		| @@ -4,8 +4,6 @@ namespace App\Actions\Server; | ||||
| 
 | ||||
| use App\Models\InstanceSettings; | ||||
| use App\Models\Server; | ||||
| use Illuminate\Support\Facades\File; | ||||
| use Illuminate\Support\Facades\Http; | ||||
| use Lorisleiva\Actions\Concerns\AsAction; | ||||
| 
 | ||||
| class UpdateCoolify | ||||
| @@ -27,11 +25,6 @@ class UpdateCoolify | ||||
|                 return; | ||||
|             } | ||||
|             CleanupDocker::dispatch($this->server)->onQueue('high'); | ||||
|             $response = Http::retry(3, 1000)->get('https://cdn.coollabs.io/coolify/versions.json'); | ||||
|             if ($response->successful()) { | ||||
|                 $versions = $response->json(); | ||||
|                 File::put(base_path('versions.json'), json_encode($versions, JSON_PRETTY_PRINT)); | ||||
|             } | ||||
|             $this->latestVersion = get_latest_version_of_coolify(); | ||||
|             $this->currentVersion = config('version'); | ||||
|             if (! $manual_update) { | ||||
|   | ||||
| @@ -1,32 +0,0 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Jobs; | ||||
| 
 | ||||
| use App\Traits\ExecuteRemoteCommand; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Contracts\Queue\ShouldBeEncrypted; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Foundation\Bus\Dispatchable; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Queue\SerializesModels; | ||||
| 
 | ||||
| class ApplicationRestartJob implements ShouldBeEncrypted, ShouldQueue | ||||
| { | ||||
|     use Dispatchable, ExecuteRemoteCommand, InteractsWithQueue, Queueable, SerializesModels; | ||||
| 
 | ||||
|     public $timeout = 3600; | ||||
| 
 | ||||
|     public $tries = 1; | ||||
| 
 | ||||
|     public string $applicationDeploymentQueueId; | ||||
| 
 | ||||
|     public function __construct(string $applicationDeploymentQueueId) | ||||
|     { | ||||
|         $this->applicationDeploymentQueueId = $applicationDeploymentQueueId; | ||||
|     } | ||||
| 
 | ||||
|     public function handle() | ||||
|     { | ||||
|         ray('Restarting application'); | ||||
|     } | ||||
| } | ||||
| @@ -1,28 +0,0 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace App\Jobs; | ||||
| 
 | ||||
| use App\Actions\Server\UpdateCoolify; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Contracts\Queue\ShouldBeEncrypted; | ||||
| use Illuminate\Contracts\Queue\ShouldBeUnique; | ||||
| use Illuminate\Contracts\Queue\ShouldQueue; | ||||
| use Illuminate\Foundation\Bus\Dispatchable; | ||||
| use Illuminate\Queue\InteractsWithQueue; | ||||
| use Illuminate\Queue\SerializesModels; | ||||
| 
 | ||||
| class InstanceAutoUpdateJob implements ShouldBeEncrypted, ShouldBeUnique, ShouldQueue | ||||
| { | ||||
|     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||||
| 
 | ||||
|     public $timeout = 600; | ||||
| 
 | ||||
|     public $tries = 1; | ||||
| 
 | ||||
|     public function __construct() {} | ||||
| 
 | ||||
|     public function handle(): void | ||||
|     { | ||||
|         UpdateCoolify::run(); | ||||
|     } | ||||
| } | ||||
| @@ -4,7 +4,6 @@ namespace App\Livewire; | ||||
| 
 | ||||
| use App\Actions\Server\UpdateCoolify; | ||||
| use App\Models\InstanceSettings; | ||||
| use Illuminate\Support\Facades\Http; | ||||
| use Livewire\Component; | ||||
| 
 | ||||
| class Upgrade extends Component | ||||
| @@ -22,13 +21,8 @@ class Upgrade extends Component | ||||
|     public function checkUpdate() | ||||
|     { | ||||
|         try { | ||||
|             $settings = InstanceSettings::get(); | ||||
|             $response = Http::retry(3, 1000)->get('https://cdn.coollabs.io/coolify/versions.json'); | ||||
|             if ($response->successful()) { | ||||
|                 $versions = $response->json(); | ||||
|                 $this->latestVersion = data_get($versions, 'coolify.v4.version'); | ||||
|             } | ||||
|             $this->isUpgradeAvailable = $settings->new_version_available; | ||||
|             $this->latestVersion = get_latest_version_of_coolify(); | ||||
|             $this->isUpgradeAvailable = data_get(InstanceSettings::get(), 'new_version_available', false); | ||||
| 
 | ||||
|         } catch (\Throwable $e) { | ||||
|             return handleError($e, $this); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Andras Bacsai
					Andras Bacsai