@@ -19,13 +19,9 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
    protected function schedule(Schedule $schedule): void
 | 
					    protected function schedule(Schedule $schedule): void
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (isDev()) {
 | 
					        if (isDev()) {
 | 
				
			||||||
            // $schedule->job(new ContainerStatusJob(Server::find(0)))->everyTenMinutes()->onOneServer();
 | 
					            $schedule->command('horizon:snapshot')->everyMinute();
 | 
				
			||||||
            // $schedule->command('horizon:snapshot')->everyMinute();
 | 
					 | 
				
			||||||
            $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer();
 | 
					            $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer();
 | 
				
			||||||
            // $schedule->job(new CheckResaleLicenseJob)->hourly();
 | 
					            $this->check_scheduled_backups($schedule);
 | 
				
			||||||
            // $schedule->job(new DockerCleanupJob)->everyOddHour();
 | 
					 | 
				
			||||||
            // $this->instance_auto_update($schedule);
 | 
					 | 
				
			||||||
            // $this->check_scheduled_backups($schedule);
 | 
					 | 
				
			||||||
            $this->check_resources($schedule);
 | 
					            $this->check_resources($schedule);
 | 
				
			||||||
            $this->cleanup_servers($schedule);
 | 
					            $this->cleanup_servers($schedule);
 | 
				
			||||||
            $this->check_scheduled_backups($schedule);
 | 
					            $this->check_scheduled_backups($schedule);
 | 
				
			||||||
@@ -69,7 +65,6 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    private function check_scheduled_backups($schedule)
 | 
					    private function check_scheduled_backups($schedule)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        ray('check_scheduled_backups');
 | 
					 | 
				
			||||||
        $scheduled_backups = ScheduledDatabaseBackup::all();
 | 
					        $scheduled_backups = ScheduledDatabaseBackup::all();
 | 
				
			||||||
        if ($scheduled_backups->isEmpty()) {
 | 
					        if ($scheduled_backups->isEmpty()) {
 | 
				
			||||||
            ray('no scheduled backups');
 | 
					            ray('no scheduled backups');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,6 +75,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
 | 
				
			|||||||
    private string $serverUserHomeDir = '/root';
 | 
					    private string $serverUserHomeDir = '/root';
 | 
				
			||||||
    private string $dockerConfigFileExists = 'NOK';
 | 
					    private string $dockerConfigFileExists = 'NOK';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int $customPort = 22;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tries = 1;
 | 
					    public $tries = 1;
 | 
				
			||||||
    public function __construct(int $application_deployment_queue_id)
 | 
					    public function __construct(int $application_deployment_queue_id)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -167,6 +169,15 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
 | 
				
			|||||||
        // Get user home directory
 | 
					        // Get user home directory
 | 
				
			||||||
        $this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server);
 | 
					        $this->serverUserHomeDir = instant_remote_process(["echo \$HOME"], $this->server);
 | 
				
			||||||
        $this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server);
 | 
					        $this->dockerConfigFileExists = instant_remote_process(["test -f {$this->serverUserHomeDir}/.docker/config.json && echo 'OK' || echo 'NOK'"], $this->server);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Check custom port
 | 
				
			||||||
 | 
					        preg_match('/(?<=:)\d+(?=\/)/', $this->application->git_repository, $matches);
 | 
				
			||||||
 | 
					        if (count($matches) === 1) {
 | 
				
			||||||
 | 
					            $this->customPort = $matches[0];
 | 
				
			||||||
 | 
					            $gitHost = str($this->application->git_repository)->before(':');
 | 
				
			||||||
 | 
					            $gitRepo = str($this->application->git_repository)->after('/');
 | 
				
			||||||
 | 
					            $this->application->git_repository = "$gitHost:$gitRepo";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            if ($this->application->dockerfile) {
 | 
					            if ($this->application->dockerfile) {
 | 
				
			||||||
                $this->deploy_simple_dockerfile();
 | 
					                $this->deploy_simple_dockerfile();
 | 
				
			||||||
@@ -549,13 +560,8 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ($this->application->deploymentType() === 'deploy_key') {
 | 
					        if ($this->application->deploymentType() === 'deploy_key') {
 | 
				
			||||||
            $port = 22;
 | 
					 | 
				
			||||||
            preg_match('/(?<=:)\d+(?=\/)/', $this->application->git_repository, $matches);
 | 
					 | 
				
			||||||
            if (count($matches) === 1) {
 | 
					 | 
				
			||||||
                $port = $matches[0];
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            $private_key = base64_encode($this->application->private_key->private_key);
 | 
					            $private_key = base64_encode($this->application->private_key->private_key);
 | 
				
			||||||
            $git_clone_command = "GIT_SSH_COMMAND=\"ssh -p $port -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" {$git_clone_command} {$this->application->git_repository} {$this->basedir}";
 | 
					            $git_clone_command = "GIT_SSH_COMMAND=\"ssh -o ConnectTimeout=30 -p {$this->customPort} -o Port={$this->customPort} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa\" {$git_clone_command} {$this->application->git_repository} {$this->basedir}";
 | 
				
			||||||
            $git_clone_command = $this->set_git_import_settings($git_clone_command);
 | 
					            $git_clone_command = $this->set_git_import_settings($git_clone_command);
 | 
				
			||||||
            $commands = collect([
 | 
					            $commands = collect([
 | 
				
			||||||
                executeInDocker($this->deployment_uuid, "mkdir -p /root/.ssh"),
 | 
					                executeInDocker($this->deployment_uuid, "mkdir -p /root/.ssh"),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,6 @@ use App\Notifications\Server\Revived;
 | 
				
			|||||||
use App\Notifications\Server\Unreachable;
 | 
					use App\Notifications\Server\Unreachable;
 | 
				
			||||||
use Illuminate\Bus\Queueable;
 | 
					use Illuminate\Bus\Queueable;
 | 
				
			||||||
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
 | 
					use Illuminate\Contracts\Queue\ShouldBeEncrypted;
 | 
				
			||||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
 | 
					 | 
				
			||||||
use Illuminate\Contracts\Queue\ShouldQueue;
 | 
					use Illuminate\Contracts\Queue\ShouldQueue;
 | 
				
			||||||
use Illuminate\Foundation\Bus\Dispatchable;
 | 
					use Illuminate\Foundation\Bus\Dispatchable;
 | 
				
			||||||
use Illuminate\Queue\InteractsWithQueue;
 | 
					use Illuminate\Queue\InteractsWithQueue;
 | 
				
			||||||
@@ -25,28 +24,23 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | 
					    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public $tries = 1;
 | 
					 | 
				
			||||||
    public $timeout = 120;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function middleware(): array
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return [(new WithoutOverlapping($this->server->uuid))->dontRelease()];
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function uniqueId(): string
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return $this->server->uuid;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function __construct(public Server $server)
 | 
					    public function __construct(public Server $server)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->handle();
 | 
					    }
 | 
				
			||||||
 | 
					    public function middleware(): array
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return [(new WithoutOverlapping($this->server->id))->dontRelease()];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function handle()
 | 
					    public function uniqueId(): int
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        return $this->server->id;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function handle(): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ray("checking server status for {$this->server->id}");
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            // ray("checking server status for {$this->server->id}");
 | 
					 | 
				
			||||||
            // ray()->clearAll();
 | 
					            // ray()->clearAll();
 | 
				
			||||||
            $serverUptimeCheckNumber = $this->server->unreachable_count;
 | 
					            $serverUptimeCheckNumber = $this->server->unreachable_count;
 | 
				
			||||||
            $serverUptimeCheckNumberMax = 3;
 | 
					            $serverUptimeCheckNumberMax = 3;
 | 
				
			||||||
@@ -305,7 +299,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
 | 
				
			|||||||
        } catch (\Throwable $e) {
 | 
					        } catch (\Throwable $e) {
 | 
				
			||||||
            send_internal_notification('ContainerStatusJob failed with: ' . $e->getMessage());
 | 
					            send_internal_notification('ContainerStatusJob failed with: ' . $e->getMessage());
 | 
				
			||||||
            ray($e->getMessage());
 | 
					            ray($e->getMessage());
 | 
				
			||||||
            return handleError($e);
 | 
					            handleError($e);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -210,13 +210,13 @@ return [
 | 
				
			|||||||
        'production' => [
 | 
					        'production' => [
 | 
				
			||||||
            's6' => [
 | 
					            's6' => [
 | 
				
			||||||
                'autoScalingStrategy' => 'size',
 | 
					                'autoScalingStrategy' => 'size',
 | 
				
			||||||
                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 10),
 | 
					                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 2),
 | 
				
			||||||
                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
					                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
				
			||||||
                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
					                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            'long-running' => [
 | 
					            'long-running' => [
 | 
				
			||||||
                'autoScalingStrategy' => 'size',
 | 
					                'autoScalingStrategy' => 'size',
 | 
				
			||||||
                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 10),
 | 
					                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 2),
 | 
				
			||||||
                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
					                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
				
			||||||
                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
					                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
@@ -225,13 +225,13 @@ return [
 | 
				
			|||||||
        'local' => [
 | 
					        'local' => [
 | 
				
			||||||
            's6' => [
 | 
					            's6' => [
 | 
				
			||||||
                'autoScalingStrategy' => 'size',
 | 
					                'autoScalingStrategy' => 'size',
 | 
				
			||||||
                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 10),
 | 
					                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 2),
 | 
				
			||||||
                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
					                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
				
			||||||
                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
					                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
            'long-running' => [
 | 
					            'long-running' => [
 | 
				
			||||||
                'autoScalingStrategy' => 'size',
 | 
					                'autoScalingStrategy' => 'size',
 | 
				
			||||||
                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 10),
 | 
					                'maxProcesses' => env('HORIZON_MAX_PROCESSES', 2),
 | 
				
			||||||
                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
					                'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1),
 | 
				
			||||||
                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
					                'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1),
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ return [
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // The release version of your application
 | 
					    // The release version of your application
 | 
				
			||||||
    // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
 | 
					    // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
 | 
				
			||||||
    'release' => '4.0.0-beta.95',
 | 
					    'release' => '4.0.0-beta.96',
 | 
				
			||||||
    // When left empty or `null` the Laravel environment will be used
 | 
					    // When left empty or `null` the Laravel environment will be used
 | 
				
			||||||
    'environment' => config('app.env'),
 | 
					    'environment' => config('app.env'),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,3 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return '4.0.0-beta.95';
 | 
					return '4.0.0-beta.96';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
            "version": "3.12.36"
 | 
					            "version": "3.12.36"
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        "v4": {
 | 
					        "v4": {
 | 
				
			||||||
            "version": "4.0.0-beta.95"
 | 
					            "version": "4.0.0-beta.96"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user