test
This commit is contained in:
parent
c90171fd5c
commit
81de9ff39e
@ -19,6 +19,7 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique
|
|||||||
private string $latest_version;
|
private string $latest_version;
|
||||||
private string $current_version;
|
private string $current_version;
|
||||||
private Server $server;
|
private Server $server;
|
||||||
|
private string $localhost_name = 'localhost';
|
||||||
public $tries = 1;
|
public $tries = 1;
|
||||||
public $timeout = 120;
|
public $timeout = 120;
|
||||||
public function uniqueId(): int
|
public function uniqueId(): int
|
||||||
@ -27,39 +28,32 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique
|
|||||||
}
|
}
|
||||||
public function __construct(private bool $force = false)
|
public function __construct(private bool $force = false)
|
||||||
{
|
{
|
||||||
if (config('app.env') === 'local') {
|
try {
|
||||||
$server_name = 'testing-local-docker-container';
|
if (config('app.env') === 'local') {
|
||||||
} else {
|
$localhost_name = 'testing-local-docker-container';
|
||||||
$server_name = 'localhost';
|
}
|
||||||
}
|
$this->server = Server::where('name', $localhost_name)->firstOrFail();
|
||||||
$server = Server::where('name', $server_name)->first();
|
$this->latest_version = get_latest_version_of_coolify();
|
||||||
if (is_null($server)) {
|
$this->current_version = config('version');
|
||||||
throw new \Exception("Server not found");
|
|
||||||
}
|
|
||||||
$this->server = $server;
|
|
||||||
$this->latest_version = get_latest_version_of_coolify();
|
|
||||||
$this->current_version = config('version');
|
|
||||||
|
|
||||||
if (!$this->force) {
|
if (!$this->force) {
|
||||||
$instance_settings = InstanceSettings::get();
|
$instance_settings = InstanceSettings::get();
|
||||||
if (!$instance_settings->is_auto_update_enabled) {
|
if (!$instance_settings->is_auto_update_enabled) {
|
||||||
return $this->delete();
|
return $this->fail('Auto update is disabled');
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
$this->check_if_update_available();
|
$this->check_if_update_available();
|
||||||
} catch (\Exception $e) {
|
|
||||||
Log::error($e->getMessage());
|
|
||||||
return $this->delete();
|
|
||||||
}
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function check_if_update_available()
|
private function check_if_update_available()
|
||||||
{
|
{
|
||||||
if ($this->latest_version === $this->current_version) {
|
if ($this->latest_version === $this->current_version) {
|
||||||
throw new \Exception("Already on latest version");
|
$this->fail("Already on latest version");
|
||||||
}
|
}
|
||||||
if (version_compare($this->latest_version, $this->current_version, '<')) {
|
if (version_compare($this->latest_version, $this->current_version, '<')) {
|
||||||
throw new \Exception("Already on latest version");
|
$this->fail("Latest version is lower than current version?!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
@ -77,6 +71,7 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique
|
|||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
$this->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user