hmm
This commit is contained in:
parent
fde7790680
commit
c81ec556db
@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
|
|
||||||
$schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();
|
$schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();
|
||||||
// $schedule->job(new InstanceAutoUpdateJob)->everyFifteenMinutes();
|
$schedule->job(new InstanceAutoUpdateJob)->everyTenMinutes();
|
||||||
$schedule->job(new InstanceProxyCheckJob)->everyMinute();
|
$schedule->job(new InstanceProxyCheckJob)->everyMinute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,10 +16,6 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique
|
|||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||||
|
|
||||||
private string $latest_version;
|
|
||||||
private string $current_version;
|
|
||||||
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
|
||||||
@ -28,46 +24,42 @@ class InstanceAutoUpdateJob implements ShouldQueue, ShouldBeUnique
|
|||||||
}
|
}
|
||||||
public function __construct(private bool $force = false)
|
public function __construct(private bool $force = false)
|
||||||
{
|
{
|
||||||
try {
|
|
||||||
if (config('app.env') === 'local') {
|
|
||||||
$localhost_name = 'testing-local-docker-container';
|
|
||||||
}
|
}
|
||||||
$this->server = Server::where('name', $localhost_name)->firstOrFail();
|
|
||||||
$this->latest_version = get_latest_version_of_coolify();
|
|
||||||
$this->current_version = config('version');
|
|
||||||
|
|
||||||
if (!$this->force) {
|
|
||||||
$instance_settings = InstanceSettings::get();
|
|
||||||
if (!$instance_settings->is_auto_update_enabled) {
|
|
||||||
return $this->fail('Auto update is disabled');
|
|
||||||
}
|
|
||||||
$this->check_if_update_available();
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private function check_if_update_available()
|
|
||||||
{
|
|
||||||
if ($this->latest_version === $this->current_version) {
|
|
||||||
$this->fail("Already on latest version");
|
|
||||||
}
|
|
||||||
if (version_compare($this->latest_version, $this->current_version, '<')) {
|
|
||||||
$this->fail("Latest version is lower than current version?!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function handle(): void
|
public function handle(): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
$localhost_name = 'localhost';
|
||||||
|
if (config('app.env') === 'local') {
|
||||||
|
$localhost_name = 'testing-local-docker-container';
|
||||||
|
}
|
||||||
|
$server = Server::where('name', $localhost_name)->firstOrFail();
|
||||||
|
$latest_version = get_latest_version_of_coolify();
|
||||||
|
$current_version = config('version');
|
||||||
|
|
||||||
if (config('app.env') === 'local') {
|
if (config('app.env') === 'local') {
|
||||||
instant_remote_process([
|
instant_remote_process([
|
||||||
"sleep 10"
|
"sleep 10"
|
||||||
], $this->server);
|
], $server);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
if (!$this->force) {
|
||||||
|
$instance_settings = InstanceSettings::get();
|
||||||
|
if (!$instance_settings->is_auto_update_enabled) {
|
||||||
|
$this->fail('Auto update is disabled');
|
||||||
|
}
|
||||||
|
if ($latest_version === $current_version) {
|
||||||
|
$this->fail("Already on latest version");
|
||||||
|
}
|
||||||
|
if (version_compare($latest_version, $current_version, '<')) {
|
||||||
|
$this->fail("Latest version is lower than current version?!");
|
||||||
|
}
|
||||||
|
}
|
||||||
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",
|
||||||
"bash /data/coolify/source/upgrade.sh $this->latest_version"
|
"bash /data/coolify/source/upgrade.sh $latest_version"
|
||||||
], $this->server);
|
], $server);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error($e->getMessage());
|
Log::error($e->getMessage());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user