diff --git a/app/Actions/CoolifyTask/RunRemoteProcess.php b/app/Actions/CoolifyTask/RunRemoteProcess.php index 1444684a0..cc4bca873 100644 --- a/app/Actions/CoolifyTask/RunRemoteProcess.php +++ b/app/Actions/CoolifyTask/RunRemoteProcess.php @@ -10,9 +10,6 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Process; use Spatie\Activitylog\Models\Activity; -const TIMEOUT = 3600; -const IDLE_TIMEOUT = 3600; - class RunRemoteProcess { public Activity $activity; @@ -76,8 +73,7 @@ class RunRemoteProcess $this->time_start = hrtime(true); $status = ProcessStatus::IN_PROGRESS; - - $processResult = Process::timeout(TIMEOUT)->idleTimeout(IDLE_TIMEOUT)->run($this->getCommand(), $this->handleOutput(...)); + $processResult = Process::forever()->run($this->getCommand(), $this->handleOutput(...)); if ($this->activity->properties->get('status') === ProcessStatus::ERROR->value) { $status = ProcessStatus::ERROR; diff --git a/app/Http/Livewire/Server/Form.php b/app/Http/Livewire/Server/Form.php index 53cf8234d..9d5c892b3 100644 --- a/app/Http/Livewire/Server/Form.php +++ b/app/Http/Livewire/Server/Form.php @@ -56,7 +56,7 @@ class Form extends Component $this->uptime = $uptime; $this->emit('success', 'Server is reachable!'); } else { - $this->emit('error', 'Server is not rachable'); + $this->emit('error', 'Server is not reachable'); return; } if ($dockerVersion) { diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php index 40ff2f958..d713e0c19 100644 --- a/bootstrap/helpers/remoteProcess.php +++ b/bootstrap/helpers/remoteProcess.php @@ -71,8 +71,12 @@ function save_private_key_for_server(Server $server) function generate_ssh_command(string $private_key_location, string $server_ip, string $user, string $port, string $command, bool $isMux = true) { + $timeout = config('constants.ssh.command_timeout'); + $connectionTimeout = config('constants.ssh.connection_timeout'); + $serverInterval = config('constants.ssh.server_interval'); + $delimiter = 'EOF-COOLIFY-SSH'; - $ssh_command = "ssh "; + $ssh_command = "timeout $timeout ssh "; if ($isMux && config('coolify.mux_enabled')) { $ssh_command .= '-o ControlMaster=auto -o ControlPersist=1m -o ControlPath=/var/www/html/storage/app/ssh/mux/%h_%p_%r '; @@ -81,8 +85,8 @@ function generate_ssh_command(string $private_key_location, string $server_ip, s $ssh_command .= "-i {$private_key_location} " . '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ' . '-o PasswordAuthentication=no ' - . '-o ConnectTimeout=3600 ' - . '-o ServerAliveInterval=20 ' + . "-o ConnectTimeout=$connectionTimeout " + . "-o ServerAliveInterval=$serverInterval " . '-o RequestTTY=no ' . '-o LogLevel=ERROR ' . "-p {$port} " @@ -90,7 +94,7 @@ function generate_ssh_command(string $private_key_location, string $server_ip, s . " 'bash -se' << \\$delimiter" . PHP_EOL . $command . PHP_EOL . $delimiter; - + ray($ssh_command); return $ssh_command; } function instantCommand(string $command, $throwError = true) { diff --git a/config/constants.php b/config/constants.php index 4cb112855..4630adcda 100644 --- a/config/constants.php +++ b/config/constants.php @@ -1,5 +1,10 @@ [ + 'connection_timeout' => 10, + 'server_interval' => 20, + 'command_timeout' => 7200, + ], 'waitlist' => [ 'expiration' => 10, ],