Compare commits

...

5 Commits

Author SHA1 Message Date
Andras Bacsai
abdb8074b1 Merge pull request #1235 from coollabsio/next
4.0.0-beta.40
2023-09-18 10:05:52 +02:00
Andras Bacsai
157da798dd fix: proxy start (if not proxy defined, use Traefik) 2023-09-18 09:58:13 +02:00
Andras Bacsai
9c5501326e Merge pull request #1230 from coollabsio/next
4.0.0-beta.39
2023-09-16 16:53:17 +02:00
Andras Bacsai
3ea462efc9 fix: localhost 2023-09-16 16:49:33 +02:00
Andras Bacsai
f77df5b732 feat: sentry add email for better support 2023-09-15 21:13:50 +02:00
8 changed files with 50 additions and 37 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Actions\Proxy; namespace App\Actions\Proxy;
use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use App\Models\Server; use App\Models\Server;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Spatie\Activitylog\Models\Activity; use Spatie\Activitylog\Models\Activity;
@@ -10,6 +12,15 @@ class StartProxy
{ {
public function __invoke(Server $server, bool $async = true): Activity|string public function __invoke(Server $server, bool $async = true): Activity|string
{ {
$proxyType = data_get($server,'proxy.type');
if ($proxyType === 'none') {
return 'OK';
}
if (is_null($proxyType)) {
$server->proxy->type = ProxyTypes::TRAEFIK_V2->value;
$server->proxy->status = ProxyStatus::EXITED->value;
$server->save();
}
$proxy_path = get_proxy_path(); $proxy_path = get_proxy_path();
$networks = collect($server->standaloneDockers)->map(function ($docker) { $networks = collect($server->standaloneDockers)->map(function ($docker) {
return $docker['network']; return $docker['network'];
@@ -38,12 +49,12 @@ class StartProxy
"echo '####### Pulling docker image...'", "echo '####### Pulling docker image...'",
'docker compose pull', 'docker compose pull',
"echo '####### Stopping existing coolify-proxy...'", "echo '####### Stopping existing coolify-proxy...'",
'docker compose down -v --remove-orphans', "docker compose down -v --remove-orphans > /dev/null 2>&1 || true",
"command -v lsof >/dev/null && lsof -nt -i:80 | xargs -r kill -9",
"command -v lsof >/dev/null && lsof -nt -i:443 | xargs -r kill -9",
"command -v fuser >/dev/null && fuser -k 80/tcp",
"command -v fuser >/dev/null && fuser -k 443/tcp",
"command -v fuser >/dev/null || command -v lsof >/dev/null || echo '####### Could not kill existing processes listening on port 80 & 443. Please stop the process holding these ports...'", "command -v fuser >/dev/null || command -v lsof >/dev/null || echo '####### Could not kill existing processes listening on port 80 & 443. Please stop the process holding these ports...'",
"command -v lsof >/dev/null && lsof -nt -i:80 | xargs -r kill -9 || true",
"command -v lsof >/dev/null && lsof -nt -i:443 | xargs -r kill -9 || true",
"command -v fuser >/dev/null && fuser -k 80/tcp || true",
"command -v fuser >/dev/null && fuser -k 443/tcp || true",
"systemctl disable nginx > /dev/null 2>&1 || true", "systemctl disable nginx > /dev/null 2>&1 || true",
"systemctl disable apache2 > /dev/null 2>&1 || true", "systemctl disable apache2 > /dev/null 2>&1 || true",
"systemctl disable apache > /dev/null 2>&1 || true", "systemctl disable apache > /dev/null 2>&1 || true",

View File

@@ -3,6 +3,7 @@
namespace App\Exceptions; namespace App\Exceptions;
use App\Models\InstanceSettings; use App\Models\InstanceSettings;
use App\Models\User;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Sentry\Laravel\Integration; use Sentry\Laravel\Integration;
use Sentry\State\Scope; use Sentry\State\Scope;
@@ -56,8 +57,8 @@ class Handler extends ExceptionHandler
function (Scope $scope) { function (Scope $scope) {
$scope->setUser( $scope->setUser(
[ [
'id' => config('sentry.server_name'), 'email' => auth()->user()->email,
'email' => auth()->user()->email 'instanceAdmin' => User::find(0)->email
] ]
); );
} }

View File

@@ -89,7 +89,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
if (!$this->createdServer) { if (!$this->createdServer) {
return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.'); return $this->emit('error', 'Localhost server is not found. Something went wrong during installation. Please try to reinstall or contact support.');
} }
return $this->validateServer(); return $this->validateServer('localhost');
} elseif ($type === 'remote') { } elseif ($type === 'remote') {
$this->privateKeys = PrivateKey::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get(); $this->privateKeys = PrivateKey::ownedByCurrentTeam(['name'])->where('id', '!=', 0)->get();
if ($this->privateKeys->count() > 0) { if ($this->privateKeys->count() > 0) {
@@ -185,7 +185,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
$this->validateServer(); $this->validateServer();
} }
public function validateServer() public function validateServer(?string $type = null)
{ {
try { try {
$customErrorMessage = "Server is not reachable:"; $customErrorMessage = "Server is not reachable:";
@@ -197,24 +197,30 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
throw new \Exception('No Docker Engine or older than 23 version installed.'); throw new \Exception('No Docker Engine or older than 23 version installed.');
} }
$customErrorMessage = "Cannot create Server or Private Key. Please try again."; $customErrorMessage = "Cannot create Server or Private Key. Please try again.";
$createdPrivateKey = PrivateKey::create([ if ($type !== 'localhost') {
'name' => $this->privateKeyName, $createdPrivateKey = PrivateKey::create([
'description' => $this->privateKeyDescription, 'name' => $this->privateKeyName,
'private_key' => $this->privateKey, 'description' => $this->privateKeyDescription,
'team_id' => currentTeam()->id 'private_key' => $this->privateKey,
]); 'team_id' => currentTeam()->id
$server = Server::create([ ]);
'name' => $this->remoteServerName, $server = Server::create([
'ip' => $this->remoteServerHost, 'name' => $this->remoteServerName,
'port' => $this->remoteServerPort, 'ip' => $this->remoteServerHost,
'user' => $this->remoteServerUser, 'port' => $this->remoteServerPort,
'description' => $this->remoteServerDescription, 'user' => $this->remoteServerUser,
'private_key_id' => $createdPrivateKey->id, 'description' => $this->remoteServerDescription,
'team_id' => currentTeam()->id, 'private_key_id' => $createdPrivateKey->id,
]); 'team_id' => currentTeam()->id,
$server->settings->is_reachable = true; ]);
$server->settings->is_usable = true; $server->settings->is_reachable = true;
$server->settings->save(); $server->settings->is_usable = true;
$server->settings->save();
} else {
$this->createdServer->settings->update([
'is_reachable' => true,
]);
}
$this->getProxyType(); $this->getProxyType();
} catch (\Throwable $e) { } catch (\Throwable $e) {
return handleError(error: $e, customErrorMessage: $customErrorMessage, livewire: $this); return handleError(error: $e, customErrorMessage: $customErrorMessage, livewire: $this);

View File

@@ -41,17 +41,15 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
} }
private function checkServerConnection() { private function checkServerConnection() {
ray("Checking server connection to {$this->server->ip}");
$uptime = instant_remote_process(['uptime'], $this->server, false); $uptime = instant_remote_process(['uptime'], $this->server, false);
if (!is_null($uptime)) { if (!is_null($uptime)) {
ray('Server is up');
return true; return true;
} }
} }
public function handle(): void public function handle(): void
{ {
try { try {
ray()->clearAll(); // ray()->clearAll();
$serverUptimeCheckNumber = 0; $serverUptimeCheckNumber = 0;
$serverUptimeCheckNumberMax = 5; $serverUptimeCheckNumberMax = 5;
while (true) { while (true) {
@@ -216,12 +214,10 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
$isPR = Str::startsWith(data_get($value, 'Name'), "/$uuid"); $isPR = Str::startsWith(data_get($value, 'Name'), "/$uuid");
$isPR = Str::contains(data_get($value, 'Name'), "-pr-"); $isPR = Str::contains(data_get($value, 'Name'), "-pr-");
if ($isPR) { if ($isPR) {
ray('is pr');
return false; return false;
} }
return $value; return $value;
})->first(); })->first();
ray($foundContainer);
if ($foundContainer) { if ($foundContainer) {
$containerStatus = data_get($foundContainer, 'State.Status'); $containerStatus = data_get($foundContainer, 'State.Status');
$databaseStatus = data_get($application, 'status'); $databaseStatus = data_get($application, 'status');

View File

@@ -7,8 +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.38', 'release' => '4.0.0-beta.40',
'server_name' => env('APP_ID', 'coolify'),
// 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'),

View File

@@ -1,3 +1,3 @@
<?php <?php
return '4.0.0-beta.38'; return '4.0.0-beta.40';

View File

@@ -3,6 +3,6 @@
<div class="">The destination server / network where your application will be deployed to.</div> <div class="">The destination server / network where your application will be deployed to.</div>
<div class="py-4 "> <div class="py-4 ">
<p>Server: {{ data_get($destination, 'server.name') }}</p> <p>Server: {{ data_get($destination, 'server.name') }}</p>
<p>Destination Network: {{ $destination->network }}</p> <p>Destination Network: {{ data_get($destination, 'server.network') }}</p>
</div> </div>
</div> </div>

View File

@@ -4,7 +4,7 @@
"version": "3.12.36" "version": "3.12.36"
}, },
"v4": { "v4": {
"version": "4.0.0-beta.38" "version": "4.0.0-beta.40"
} }
} }
} }