Refactor logging in PushServerUpdateJob, Application, and SentinelSeeder
This commit is contained in:
@@ -63,6 +63,7 @@ class PushServerUpdateJob implements ShouldQueue
|
|||||||
public Collection $foundApplicationPreviewsIds;
|
public Collection $foundApplicationPreviewsIds;
|
||||||
|
|
||||||
public bool $foundProxy = false;
|
public bool $foundProxy = false;
|
||||||
|
|
||||||
public bool $foundLogDrainContainer = false;
|
public bool $foundLogDrainContainer = false;
|
||||||
|
|
||||||
public function backoff(): int
|
public function backoff(): int
|
||||||
@@ -204,7 +205,8 @@ class PushServerUpdateJob implements ShouldQueue
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function serverStatus(){
|
private function serverStatus()
|
||||||
|
{
|
||||||
if ($this->server->isFunctional() === false) {
|
if ($this->server->isFunctional() === false) {
|
||||||
throw new \Exception('Server is not ready.');
|
throw new \Exception('Server is not ready.');
|
||||||
}
|
}
|
||||||
@@ -212,6 +214,7 @@ class PushServerUpdateJob implements ShouldQueue
|
|||||||
throw new \Exception('Server is not reachable.');
|
throw new \Exception('Server is not reachable.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateApplicationStatus(string $applicationId, string $containerStatus)
|
private function updateApplicationStatus(string $applicationId, string $containerStatus)
|
||||||
{
|
{
|
||||||
$application = $this->applications->where('id', $applicationId)->first();
|
$application = $this->applications->where('id', $applicationId)->first();
|
||||||
@@ -278,7 +281,6 @@ class PushServerUpdateJob implements ShouldQueue
|
|||||||
StartProxy::run($this->server, false);
|
StartProxy::run($this->server, false);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
logger()->error($e);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$connectProxyToDockerNetworks = connectProxyToNetworks($this->server);
|
$connectProxyToDockerNetworks = connectProxyToNetworks($this->server);
|
||||||
@@ -396,7 +398,8 @@ class PushServerUpdateJob implements ShouldQueue
|
|||||||
return str($containerStatus)->contains('running');
|
return str($containerStatus)->contains('running');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkLogDrainContainer(){
|
private function checkLogDrainContainer()
|
||||||
|
{
|
||||||
if ($this->server->isLogDrainEnabled() && $this->foundLogDrainContainer === false) {
|
if ($this->server->isLogDrainEnabled() && $this->foundLogDrainContainer === false) {
|
||||||
InstallLogDrain::dispatch($this->server);
|
InstallLogDrain::dispatch($this->server);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1427,9 +1427,11 @@ class Application extends BaseModel
|
|||||||
$parsedCollection = collect($metrics)->map(function ($metric) {
|
$parsedCollection = collect($metrics)->map(function ($metric) {
|
||||||
return [(int) $metric['time'], (float) $metric['percent']];
|
return [(int) $metric['time'], (float) $metric['percent']];
|
||||||
});
|
});
|
||||||
|
|
||||||
return $parsedCollection->toArray();
|
return $parsedCollection->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMemoryMetrics(int $mins = 5)
|
public function getMemoryMetrics(int $mins = 5)
|
||||||
{
|
{
|
||||||
$server = $this->destination->server;
|
$server = $this->destination->server;
|
||||||
@@ -1455,9 +1457,9 @@ class Application extends BaseModel
|
|||||||
}
|
}
|
||||||
$metrics = json_decode($metrics, true);
|
$metrics = json_decode($metrics, true);
|
||||||
$parsedCollection = collect($metrics)->map(function ($metric) {
|
$parsedCollection = collect($metrics)->map(function ($metric) {
|
||||||
logger($metric);
|
|
||||||
return [(int) $metric['time'], (float) $metric['used']];
|
return [(int) $metric['time'], (float) $metric['used']];
|
||||||
});
|
});
|
||||||
|
|
||||||
return $parsedCollection->toArray();
|
return $parsedCollection->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1492,6 +1494,7 @@ class Application extends BaseModel
|
|||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setConfig($config)
|
public function setConfig($config)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class SentinelSeeder extends Seeder
|
|||||||
}
|
}
|
||||||
if (str($server->settings->sentinel_custom_url)->isEmpty()) {
|
if (str($server->settings->sentinel_custom_url)->isEmpty()) {
|
||||||
$url = $server->generateSentinelUrl();
|
$url = $server->generateSentinelUrl();
|
||||||
logger()->info("Setting sentinel custom url for server {$server->id} to {$url}");
|
|
||||||
$server->settings->sentinel_custom_url = $url;
|
$server->settings->sentinel_custom_url = $url;
|
||||||
$server->settings->save();
|
$server->settings->save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,12 +148,12 @@ Route::group([
|
|||||||
return response()->json(['message' => 'Server not found'], 404);
|
return response()->json(['message' => 'Server not found'], 404);
|
||||||
}
|
}
|
||||||
if ($server->settings->sentinel_token !== $naked_token) {
|
if ($server->settings->sentinel_token !== $naked_token) {
|
||||||
logger('Unauthorized');
|
|
||||||
return response()->json(['message' => 'Unauthorized'], 401);
|
return response()->json(['message' => 'Unauthorized'], 401);
|
||||||
}
|
}
|
||||||
$data = request()->all();
|
$data = request()->all();
|
||||||
|
|
||||||
PushServerUpdateJob::dispatch($server, $data);
|
PushServerUpdateJob::dispatch($server, $data);
|
||||||
|
|
||||||
return response()->json(['message' => 'ok'], 200);
|
return response()->json(['message' => 'ok'], 200);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user