fix
This commit is contained in:
		@@ -3,13 +3,23 @@
 | 
				
			|||||||
namespace App\Http\Livewire;
 | 
					namespace App\Http\Livewire;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use App\Jobs\InstanceAutoUpdateJob;
 | 
					use App\Jobs\InstanceAutoUpdateJob;
 | 
				
			||||||
 | 
					use App\Models\Server;
 | 
				
			||||||
use Livewire\Component;
 | 
					use Livewire\Component;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ForceUpgrade extends Component
 | 
					class ForceUpgrade extends Component
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    public function upgrade()
 | 
					    public function upgrade()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->emit('updateInitiated');
 | 
					        try {
 | 
				
			||||||
        dispatch(new InstanceAutoUpdateJob(force: true));
 | 
					            $server_name = 'localhost';
 | 
				
			||||||
 | 
					            if (config('app.env') === 'local') {
 | 
				
			||||||
 | 
					                $server_name = 'testing-local-docker-container';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $server = Server::where('name', $server_name)->firstOrFail();
 | 
				
			||||||
 | 
					            $this->emit('updateInitiated');
 | 
				
			||||||
 | 
					            dispatch(new InstanceAutoUpdateJob(force: true, server: $server));
 | 
				
			||||||
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
 | 
					            return general_error_handler($e, $this);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Jobs;
 | 
					namespace App\Jobs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use App\Enums\ActivityTypes;
 | 
					 | 
				
			||||||
use App\Models\InstanceSettings;
 | 
					use App\Models\InstanceSettings;
 | 
				
			||||||
use App\Models\Server;
 | 
					use App\Models\Server;
 | 
				
			||||||
use Illuminate\Bus\Queueable;
 | 
					use Illuminate\Bus\Queueable;
 | 
				
			||||||
@@ -19,29 +18,27 @@ class InstanceAutoUpdateJob implements ShouldQueue
 | 
				
			|||||||
    private string $latest_version;
 | 
					    private string $latest_version;
 | 
				
			||||||
    private string $current_version;
 | 
					    private string $current_version;
 | 
				
			||||||
    private Server $server;
 | 
					    private Server $server;
 | 
				
			||||||
    private string $server_name = 'localhost';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct(private bool $force = false)
 | 
					    public function __construct(private bool $force = false, Server|null $server = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (config('app.env') === 'local') {
 | 
					        if (is_null($server)) {
 | 
				
			||||||
            $this->server_name = 'coolify-testing-host';
 | 
					            if (config('app.env') === 'local') {
 | 
				
			||||||
 | 
					                $server_name = 'testing-local-docker-container';
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                $server_name = 'localhost';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $this->server = Server::where('name', $server_name)->first();
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $this->server = $server;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $instance_settings = InstanceSettings::get();
 | 
					        $instance_settings = InstanceSettings::get();
 | 
				
			||||||
        $this->server = Server::where('name', $this->server_name)->firstOrFail();
 | 
					 | 
				
			||||||
        Log::info('Force: ' . $this->force);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->latest_version = get_latest_version_of_coolify();
 | 
					        $this->latest_version = get_latest_version_of_coolify();
 | 
				
			||||||
        Log::info('Latest version: ' . $this->latest_version);
 | 
					 | 
				
			||||||
        $this->current_version = config('version');
 | 
					        $this->current_version = config('version');
 | 
				
			||||||
        Log::info('Current version: ' . $this->current_version);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!$this->force) {
 | 
					        if (!$this->force) {
 | 
				
			||||||
            Log::info("Checking if auto update enabled");
 | 
					            if (!$instance_settings->is_auto_update_enabled) {
 | 
				
			||||||
            if (!$instance_settings->is_auto_update_enabled || !$this->server) {
 | 
					 | 
				
			||||||
                return $this->delete();
 | 
					                return $this->delete();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            Log::info('Checking if update available');
 | 
					 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                $this->check_if_update_available();
 | 
					                $this->check_if_update_available();
 | 
				
			||||||
            } catch (\Exception $e) {
 | 
					            } catch (\Exception $e) {
 | 
				
			||||||
@@ -70,11 +67,9 @@ class InstanceAutoUpdateJob implements ShouldQueue
 | 
				
			|||||||
                    "sleep 10"
 | 
					                    "sleep 10"
 | 
				
			||||||
                ], $this->server);
 | 
					                ], $this->server);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                Log::info('Downloading upgrade script');
 | 
					 | 
				
			||||||
                instant_remote_process([
 | 
					                instant_remote_process([
 | 
				
			||||||
                    "curl -fsSL https://coolify-cdn.b-cdn.net/files/upgrade.sh -o /data/coolify/source/upgrade.sh",
 | 
					                    "curl -fsSL https://coolify-cdn.b-cdn.net/files/upgrade.sh -o /data/coolify/source/upgrade.sh",
 | 
				
			||||||
                ], $this->server);
 | 
					                ], $this->server);
 | 
				
			||||||
                Log::info('Running upgrade script');
 | 
					 | 
				
			||||||
                remote_process([
 | 
					                remote_process([
 | 
				
			||||||
                    "bash /data/coolify/source/upgrade.sh $this->latest_version"
 | 
					                    "bash /data/coolify/source/upgrade.sh $this->latest_version"
 | 
				
			||||||
                ], $this->server);
 | 
					                ], $this->server);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user