diff --git a/src/cli/CronJobs/UpdateCronJob.php b/src/cli/CronJobs/UpdateCronJob.php index 6bfd24b3..6fa6df1c 100644 --- a/src/cli/CronJobs/UpdateCronJob.php +++ b/src/cli/CronJobs/UpdateCronJob.php @@ -24,6 +24,11 @@ class UpdateCronJob implements CommandInterface { global $db, $gitRelease; + if (!$gitRelease) { + FileLogger::log('cron', 'GitRelease service not initialized', 'cron:update'); + return 1; + } + $rConfig = parse_ini_string(file_get_contents('/home/xc_vm/config/config.ini')); if (!isset($rConfig['is_lb']) || !$rConfig['is_lb']) { $rPort = (intval(explode(';', explode(' ', trim(explode('listen ', file_get_contents('/home/xc_vm/bin/nginx/conf/ports/http.conf'))[1]))[0])[0]) ?: 80); diff --git a/src/cli/DaemonTrait.php b/src/cli/DaemonTrait.php index bfee1ef2..0bd7af86 100644 --- a/src/cli/DaemonTrait.php +++ b/src/cli/DaemonTrait.php @@ -35,9 +35,9 @@ trait DaemonTrait { */ protected function killStaleProcesses(string $rPattern): void { $rPID = intval(getmypid()); - $rPids = trim(shell_exec('ps aux | grep ' . escapeshellarg($rPattern) . ' | grep -v grep | grep -v ' . $rPID . " | awk '{print \$2}'") ?? ''); + $rPids = trim(@shell_exec('ps aux | grep ' . escapeshellarg($rPattern) . ' | grep -v grep | grep -v ' . $rPID . " | awk '{print \$2}'") ?? ''); if ($rPids !== '') { - shell_exec('kill -9 ' . $rPids . ' > /dev/null 2>&1'); + @shell_exec('kill -9 ' . $rPids . ' > /dev/null 2>&1'); } } diff --git a/src/core/Database/Database.php b/src/core/Database/Database.php index 06f8aa49..18f7a659 100644 --- a/src/core/Database/Database.php +++ b/src/core/Database/Database.php @@ -129,7 +129,8 @@ class Database { $this->result = $this->dbh->prepare($query); $this->result->execute($next_arg_list); } catch (Exception $e) { - $actual_query = trim(explode("\n", explode('Sent SQL:', $this->debugString($this->result))[1])[0]); + $rDebugParts = explode('Sent SQL:', $this->debugString($this->result)); + $actual_query = isset($rDebugParts[1]) ? trim(explode("\n", $rDebugParts[1])[0]) : ''; if (strlen($actual_query) == 0) { $actual_query = $query; diff --git a/src/core/Process/ProcessManager.php b/src/core/Process/ProcessManager.php index 522c0b73..66398a21 100644 --- a/src/core/Process/ProcessManager.php +++ b/src/core/Process/ProcessManager.php @@ -475,7 +475,7 @@ class ProcessManager { */ public static function isNginxRunning() { $rOutput = []; - exec('pgrep -u xc_vm -a 2>/dev/null', $rOutput); + @exec('pgrep -u xc_vm -a 2>/dev/null', $rOutput); foreach ($rOutput as $rProcess) { if (preg_match('/nginx:\s+master/', $rProcess)) { return true;