This commit is contained in:
Andras Bacsai 2023-05-25 14:23:49 +02:00
parent 2445c0e464
commit 56abe0e5a5
4 changed files with 9 additions and 48 deletions

View File

@ -2,9 +2,9 @@
namespace App\Console;
use App\Jobs\InstanceAutoUpdate;
use App\Jobs\InstanceAutoUpdateJob;
use App\Jobs\InstanceProxyCheckJob;
use App\Jobs\InstanceDockerCleanup;
use App\Jobs\InstanceDockerCleanupJob;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@ -17,8 +17,8 @@ protected function schedule(Schedule $schedule): void
{
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->job(new InstanceDockerCleanup)->everyFiveMinutes();
$schedule->job(new InstanceAutoUpdate)->everyFifteenMinutes();
$schedule->job(new InstanceDockerCleanupJob)->everyFiveMinutes();
$schedule->job(new InstanceAutoUpdateJob)->everyFifteenMinutes();
$schedule->job(new InstanceProxyCheckJob)->everyMinute();
}

View File

@ -2,51 +2,14 @@
namespace App\Http\Livewire;
use App\Enums\ActivityTypes;
use App\Models\Server;
use App\Jobs\InstanceAutoUpdateJob;
use Livewire\Component;
class ForceUpgrade extends Component
{
public function upgrade()
{
if (config('app.env') === 'local') {
$server = Server::where('ip', 'coolify-testing-host')->first();
if (!$server) {
return;
}
instant_remote_process([
"sleep 2"
], $server);
remote_process([
"sleep 10"
], $server, ActivityTypes::INLINE->value);
$this->emit('updateInitiated');
} else {
$latestVersion = get_latest_version_of_coolify();
$cdn = "https://coolify-cdn.b-cdn.net/files";
$server = Server::where('ip', 'host.docker.internal')->first();
if (!$server) {
return;
}
instant_remote_process([
"curl -fsSL $cdn/docker-compose.yml -o /data/coolify/source/docker-compose.yml",
"curl -fsSL $cdn/docker-compose.prod.yml -o /data/coolify/source/docker-compose.prod.yml",
"curl -fsSL $cdn/.env.production -o /data/coolify/source/.env.production",
"curl -fsSL $cdn/upgrade.sh -o /data/coolify/source/upgrade.sh",
], $server);
instant_remote_process([
"docker compose -f /data/coolify/source/docker-compose.yml -f /data/coolify/source/docker-compose.prod.yml pull",
], $server);
remote_process([
"bash /data/coolify/source/upgrade.sh $latestVersion"
], $server, ActivityTypes::INLINE->value);
$this->emit('updateInitiated');
}
dispatch(new InstanceAutoUpdateJob());
$this->emit('updateInitiated');
}
}

View File

@ -10,9 +10,8 @@
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class InstanceAutoUpdate implements ShouldQueue
class InstanceAutoUpdateJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

View File

@ -4,14 +4,13 @@
use App\Models\Server;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class InstanceDockerCleanup implements ShouldQueue
class InstanceDockerCleanupJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $timeout = 500;