This commit is contained in:
Andras Bacsai
2024-11-06 15:16:12 +01:00
parent a097f3b830
commit 695ab93cf0
4 changed files with 22 additions and 13 deletions

View File

@@ -9,6 +9,7 @@ use App\Jobs\ApplicationDeploymentJob;
use App\Models\Server; use App\Models\Server;
use Illuminate\Process\ProcessResult; use Illuminate\Process\ProcessResult;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Process; use Illuminate\Support\Facades\Process;
use Spatie\Activitylog\Models\Activity; use Spatie\Activitylog\Models\Activity;
@@ -124,6 +125,7 @@ class RunRemoteProcess
])); ]));
} }
} catch (\Throwable $e) { } catch (\Throwable $e) {
Log::error('Error calling event: '.$e->getMessage());
} }
} }

View File

@@ -4,6 +4,7 @@ namespace App\Actions\Proxy;
use App\Enums\ProxyTypes; use App\Enums\ProxyTypes;
use App\Models\Server; use App\Models\Server;
use Illuminate\Support\Facades\Log;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
use Symfony\Component\Yaml\Yaml; use Symfony\Component\Yaml\Yaml;
@@ -88,6 +89,7 @@ class CheckProxy
$portsToCheck = []; $portsToCheck = [];
} }
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('Error checking proxy: '.$e->getMessage());
} }
if (count($portsToCheck) === 0) { if (count($portsToCheck) === 0) {
return false; return false;

View File

@@ -4,6 +4,7 @@ namespace App\Actions\Service;
use App\Actions\Server\CleanupDocker; use App\Actions\Server\CleanupDocker;
use App\Models\Service; use App\Models\Service;
use Illuminate\Support\Facades\Log;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
class DeleteService class DeleteService
@@ -39,7 +40,8 @@ class DeleteService
if (! empty($commands)) { if (! empty($commands)) {
foreach ($commands as $command) { foreach ($commands as $command) {
$result = instant_remote_process([$command], $server, false); $result = instant_remote_process([$command], $server, false);
if ($result !== 0) { if ($result !== null && $result !== 0) {
Log::error('Error deleting volumes: '.$result);
} }
} }
} }

View File

@@ -30,11 +30,17 @@ class Kernel extends ConsoleKernel
private InstanceSettings $settings; private InstanceSettings $settings;
private string $updateCheckFrequency;
private string $instanceTimezone;
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
{ {
$this->allServers = Server::where('ip', '!=', '1.2.3.4'); $this->allServers = Server::where('ip', '!=', '1.2.3.4');
$this->settings = instanceSettings(); $this->settings = instanceSettings();
$this->updateCheckFrequency = $this->settings->update_check_frequency ?: '0 * * * *';
$this->instanceTimezone = $this->settings->instance_timezone ?: config('app.timezone');
$schedule->job(new CleanupStaleMultiplexedConnections)->hourly(); $schedule->job(new CleanupStaleMultiplexedConnections)->hourly();
@@ -56,7 +62,7 @@ class Kernel extends ConsoleKernel
// Instance Jobs // Instance Jobs
$schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->command('cleanup:unreachable-servers')->daily()->onOneServer(); $schedule->command('cleanup:unreachable-servers')->daily()->onOneServer();
$schedule->job(new PullTemplatesFromCDN)->cron($this->settings->update_check_frequency)->timezone($this->settings->instance_timezone)->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($this->updateCheckFrequency)->timezone($this->instanceTimezone)->onOneServer();
$schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer();
$this->scheduleUpdates($schedule); $this->scheduleUpdates($schedule);
@@ -80,28 +86,27 @@ class Kernel extends ConsoleKernel
if ($server->isSentinelEnabled()) { if ($server->isSentinelEnabled()) {
$schedule->job(function () use ($server) { $schedule->job(function () use ($server) {
CheckAndStartSentinelJob::dispatch($server); CheckAndStartSentinelJob::dispatch($server);
})->cron($this->settings->update_check_frequency)->timezone($this->settings->instance_timezone)->onOneServer(); })->cron($this->updateCheckFrequency)->timezone($this->instanceTimezone)->onOneServer();
} }
} }
$schedule->job(new CheckHelperImageJob) $schedule->job(new CheckHelperImageJob)
->cron($this->settings->update_check_frequency) ->cron($this->updateCheckFrequency)
->timezone($this->settings->instance_timezone) ->timezone($this->instanceTimezone)
->onOneServer(); ->onOneServer();
} }
private function scheduleUpdates($schedule): void private function scheduleUpdates($schedule): void
{ {
$updateCheckFrequency = $this->settings->update_check_frequency;
$schedule->job(new CheckForUpdatesJob) $schedule->job(new CheckForUpdatesJob)
->cron($updateCheckFrequency) ->cron($this->updateCheckFrequency)
->timezone($this->settings->instance_timezone) ->timezone($this->instanceTimezone)
->onOneServer(); ->onOneServer();
if ($this->settings->is_auto_update_enabled) { if ($this->settings->is_auto_update_enabled) {
$autoUpdateFrequency = $this->settings->auto_update_frequency; $autoUpdateFrequency = $this->settings->auto_update_frequency;
$schedule->job(new UpdateCoolifyJob) $schedule->job(new UpdateCoolifyJob)
->cron($autoUpdateFrequency) ->cron($autoUpdateFrequency)
->timezone($this->settings->instance_timezone) ->timezone($this->instanceTimezone)
->onOneServer(); ->onOneServer();
} }
} }
@@ -166,14 +171,13 @@ class Kernel extends ConsoleKernel
if (is_null($server)) { if (is_null($server)) {
continue; continue;
} }
$serverTimezone = $server->settings->server_timezone;
if (isset(VALID_CRON_STRINGS[$scheduled_backup->frequency])) { if (isset(VALID_CRON_STRINGS[$scheduled_backup->frequency])) {
$scheduled_backup->frequency = VALID_CRON_STRINGS[$scheduled_backup->frequency]; $scheduled_backup->frequency = VALID_CRON_STRINGS[$scheduled_backup->frequency];
} }
$schedule->job(new DatabaseBackupJob( $schedule->job(new DatabaseBackupJob(
backup: $scheduled_backup backup: $scheduled_backup
))->cron($scheduled_backup->frequency)->timezone($serverTimezone)->onOneServer(); ))->cron($scheduled_backup->frequency)->timezone($this->instanceTimezone)->onOneServer();
} }
} }
@@ -207,14 +211,13 @@ class Kernel extends ConsoleKernel
if (! $server) { if (! $server) {
continue; continue;
} }
$serverTimezone = $server->settings->server_timezone ?: config('app.timezone');
if (isset(VALID_CRON_STRINGS[$scheduled_task->frequency])) { if (isset(VALID_CRON_STRINGS[$scheduled_task->frequency])) {
$scheduled_task->frequency = VALID_CRON_STRINGS[$scheduled_task->frequency]; $scheduled_task->frequency = VALID_CRON_STRINGS[$scheduled_task->frequency];
} }
$schedule->job(new ScheduledTaskJob( $schedule->job(new ScheduledTaskJob(
task: $scheduled_task task: $scheduled_task
))->cron($scheduled_task->frequency)->timezone($serverTimezone)->onOneServer(); ))->cron($scheduled_task->frequency)->timezone($this->instanceTimezone)->onOneServer();
} }
} }