diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index d28a399b9..46149444f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -4,10 +4,10 @@ namespace App\Console; use App\Jobs\CheckForUpdatesJob; use App\Jobs\CleanupInstanceStuffsJob; +use App\Jobs\CleanupSshKeysJob; use App\Jobs\CleanupStaleMultiplexedConnections; use App\Jobs\DatabaseBackupJob; use App\Jobs\DockerCleanupJob; -use App\Jobs\CleanupSshKeysJob; use App\Jobs\PullHelperImageJob; use App\Jobs\PullSentinelImageJob; use App\Jobs\PullTemplatesFromCDN; @@ -46,6 +46,7 @@ class Kernel extends ConsoleKernel $schedule->command('telescope:prune')->daily(); $schedule->job(new CleanupSshKeysJob)->weekly()->onOneServer(); + $schedule->job(new PullHelperImageJob)->everyFiveMinutes()->onOneServer(); } else { // Instance Jobs $schedule->command('horizon:snapshot')->everyFiveMinutes(); @@ -82,11 +83,11 @@ class Kernel extends ConsoleKernel } })->cron($settings->update_check_frequency)->timezone($settings->instance_timezone)->onOneServer(); } - $schedule->job(new PullHelperImageJob($server)) - ->cron($settings->update_check_frequency) - ->timezone($settings->instance_timezone) - ->onOneServer(); } + $schedule->job(new PullHelperImageJob) + ->cron($settings->update_check_frequency) + ->timezone($settings->instance_timezone) + ->onOneServer(); } private function schedule_updates($schedule) diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index df7daa3b4..e3fe455c3 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -968,7 +968,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue } } if ($this->application->environment_variables->where('key', 'COOLIFY_URL')->isEmpty()) { - $url = str($this->application->fqdn)->replace('http://', '').replace('https://', ''); + $url = str($this->application->fqdn)->replace('http://', '')->replace('https://', ''); if ($this->application->compose_parsing_version === '3') { $envs->push("COOLIFY_FQDN={$url}"); } else { @@ -1441,7 +1441,7 @@ class ApplicationDeploymentJob implements ShouldBeEncrypted, ShouldQueue if ($this->pull_request_id !== 0) { $local_branch = "pull/{$this->pull_request_id}/head"; } - $private_key = $this->application->privateKey->getKeyLocation(); + $private_key = $this->application->privateKey?->getKeyLocation(); if ($private_key) { $this->execute_remote_command( [ diff --git a/app/Jobs/PullHelperImageJob.php b/app/Jobs/PullHelperImageJob.php index 63b7fa920..ef1659680 100644 --- a/app/Jobs/PullHelperImageJob.php +++ b/app/Jobs/PullHelperImageJob.php @@ -9,7 +9,6 @@ use Illuminate\Contracts\Queue\ShouldBeEncrypted; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; -use Illuminate\Queue\Middleware\WithoutOverlapping; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Http; @@ -19,17 +18,7 @@ class PullHelperImageJob implements ShouldBeEncrypted, ShouldQueue public $timeout = 1000; - public function middleware(): array - { - return [(new WithoutOverlapping($this->server->uuid))]; - } - - public function uniqueId(): string - { - return $this->server->uuid; - } - - public function __construct(public Server $server) {} + public function __construct() {} public function handle(): void { diff --git a/app/Livewire/Project/Shared/Terminal.php b/app/Livewire/Project/Shared/Terminal.php index 802e65a30..5fd098e9f 100644 --- a/app/Livewire/Project/Shared/Terminal.php +++ b/app/Livewire/Project/Shared/Terminal.php @@ -2,6 +2,7 @@ namespace App\Livewire\Project\Shared; +use App\Helpers\SshMultiplexingHelper; use App\Models\Server; use Livewire\Attributes\On; use Livewire\Component; @@ -19,9 +20,9 @@ class Terminal extends Component if ($status !== 'running') { return; } - $command = generateSshCommand($server, "docker exec -it {$identifier} sh -c 'if [ -f ~/.profile ]; then . ~/.profile; fi; if [ -n \"\$SHELL\" ]; then exec \$SHELL; else sh; fi'"); + $command = SshMultiplexingHelper::generateSshCommand($server, "docker exec -it {$identifier} sh -c 'if [ -f ~/.profile ]; then . ~/.profile; fi; if [ -n \"\$SHELL\" ]; then exec \$SHELL; else sh; fi'"); } else { - $command = generateSshCommand($server, "sh -c 'if [ -f ~/.profile ]; then . ~/.profile; fi; if [ -n \"\$SHELL\" ]; then exec \$SHELL; else sh; fi'"); + $command = SshMultiplexingHelper::generateSshCommand($server, "sh -c 'if [ -f ~/.profile ]; then . ~/.profile; fi; if [ -n \"\$SHELL\" ]; then exec \$SHELL; else sh; fi'"); } // ssh command is sent back to frontend then to websocket diff --git a/app/Livewire/Security/PrivateKey/Show.php b/app/Livewire/Security/PrivateKey/Show.php index 14d2ed767..249c84f14 100644 --- a/app/Livewire/Security/PrivateKey/Show.php +++ b/app/Livewire/Security/PrivateKey/Show.php @@ -29,7 +29,7 @@ class Show extends Component try { $this->private_key = PrivateKey::ownedByCurrentTeam(['name', 'description', 'private_key', 'is_git_related'])->whereUuid(request()->private_key_uuid)->firstOrFail(); } catch (\Throwable $e) { - return handleError($e, $this); + abort(404); } } @@ -46,6 +46,7 @@ class Show extends Component try { $this->private_key->safeDelete(); currentTeam()->privateKeys = PrivateKey::where('team_id', currentTeam()->id)->get(); + return redirect()->route('security.private-key.index'); } catch (\Exception $e) { $this->dispatch('error', $e->getMessage()); @@ -58,7 +59,7 @@ class Show extends Component { try { $this->private_key->updatePrivateKey([ - 'private_key' => formatPrivateKey($this->private_key->private_key) + 'private_key' => formatPrivateKey($this->private_key->private_key), ]); refresh_server_connection($this->private_key); $this->dispatch('success', 'Private key updated.');