bug fix in updater
This commit is contained in:
parent
e37dded823
commit
474a1eff10
|
@ -16,7 +16,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
|
||||||
#[AsCommand(
|
#[AsCommand(
|
||||||
name: 'hesabix:update',
|
name: 'hesabix:update',
|
||||||
description: 'Updates the software by pulling from GitHub, clearing cache, updating the database, and rebuilding the frontend.'
|
description: 'Updates the software by pulling from GitHub, clearing cache, updating the database, and building the frontend.'
|
||||||
)]
|
)]
|
||||||
class UpdateSoftwareCommand extends Command
|
class UpdateSoftwareCommand extends Command
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@ class UpdateSoftwareCommand extends Command
|
||||||
private string $backupDir;
|
private string $backupDir;
|
||||||
private string $stateFile;
|
private string $stateFile;
|
||||||
private string $env;
|
private string $env;
|
||||||
|
private string $webUIDir;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, LockFactory $lockFactory, ParameterBagInterface $params)
|
public function __construct(LoggerInterface $logger, LockFactory $lockFactory, ParameterBagInterface $params)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +40,7 @@ class UpdateSoftwareCommand extends Command
|
||||||
$this->rootDir = dirname($this->appDir);
|
$this->rootDir = dirname($this->appDir);
|
||||||
$this->archiveDir = $this->rootDir . '/hesabixArchive';
|
$this->archiveDir = $this->rootDir . '/hesabixArchive';
|
||||||
$this->backupDir = $this->rootDir . '/hesabixBackup';
|
$this->backupDir = $this->rootDir . '/hesabixBackup';
|
||||||
|
$this->webUIDir = $this->rootDir . '/webUI'; // مسیر پوشه فرانتاند
|
||||||
$envConfig = file_exists($this->appDir . '/.env.local.php') ? require $this->appDir . '/.env.local.php' : [];
|
$envConfig = file_exists($this->appDir . '/.env.local.php') ? require $this->appDir . '/.env.local.php' : [];
|
||||||
$this->env = $envConfig['APP_ENV'] ?? getenv('APP_ENV') ?: 'prod';
|
$this->env = $envConfig['APP_ENV'] ?? getenv('APP_ENV') ?: 'prod';
|
||||||
$this->logger->info("Environment detected: " . $this->env);
|
$this->logger->info("Environment detected: " . $this->env);
|
||||||
|
@ -52,8 +54,6 @@ class UpdateSoftwareCommand extends Command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$lock = $this->lockFactory->createLock('hesabix-update', 3600);
|
$lock = $this->lockFactory->createLock('hesabix-update', 3600);
|
||||||
if (!$lock->acquire()) {
|
if (!$lock->acquire()) {
|
||||||
$this->writeOutput($output, '<error>Another update process is currently running. Please try again later.</error>');
|
$this->writeOutput($output, '<error>Another update process is currently running. Please try again later.</error>');
|
||||||
|
@ -93,7 +93,6 @@ class UpdateSoftwareCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$state['completedSteps'] = $state['completedSteps'] ?? [];
|
$state['completedSteps'] = $state['completedSteps'] ?? [];
|
||||||
$webUIDir = $this->rootDir . '/webUI'; // مسیر دایرکتوری فرانتاند
|
|
||||||
|
|
||||||
$gitHeadBefore = null;
|
$gitHeadBefore = null;
|
||||||
$cacheBackup = null;
|
$cacheBackup = null;
|
||||||
|
@ -114,7 +113,7 @@ class UpdateSoftwareCommand extends Command
|
||||||
mkdir($archiveBackupDir, 0755, true);
|
mkdir($archiveBackupDir, 0755, true);
|
||||||
}
|
}
|
||||||
$archiveBackup = $archiveBackupDir . '/hesabixArchive_backup_' . time() . '.tar';
|
$archiveBackup = $archiveBackupDir . '/hesabixArchive_backup_' . time() . '.tar';
|
||||||
$this->runProcess(['tar', '-cf', $archiveBackup, '-C', $this->rootDir, 'hesabixArchive'], $this->rootDir, $output, 3, 3600);
|
$this->runProcess(['tar', '-cf', $archiveBackup, '-C', $this->rootDir, 'hesabixArchive'], $this->rootDir, $output, 3);
|
||||||
$state['archiveBackup'] = $archiveBackup;
|
$state['archiveBackup'] = $archiveBackup;
|
||||||
$archiveHashBefore = $this->getDirectoryHash($this->archiveDir);
|
$archiveHashBefore = $this->getDirectoryHash($this->archiveDir);
|
||||||
$state['archiveHashBefore'] = $archiveHashBefore;
|
$state['archiveHashBefore'] = $archiveHashBefore;
|
||||||
|
@ -127,11 +126,11 @@ class UpdateSoftwareCommand extends Command
|
||||||
|
|
||||||
if (!in_array('git_pull', $state['completedSteps'])) {
|
if (!in_array('git_pull', $state['completedSteps'])) {
|
||||||
$this->writeOutput($output, 'Setting up tracking for master branch...');
|
$this->writeOutput($output, 'Setting up tracking for master branch...');
|
||||||
$this->runProcess(['git', 'branch', '--set-upstream-to=origin/master', 'master'], $this->rootDir, $output, 1, 3600);
|
$this->runProcess(['git', 'branch', '--set-upstream-to=origin/master', 'master'], $this->rootDir, $output, 1);
|
||||||
|
|
||||||
$this->writeOutput($output, 'Pulling latest changes from GitHub...');
|
$this->writeOutput($output, 'Pulling latest changes from GitHub...');
|
||||||
$gitHeadBefore = $this->getCurrentGitHead();
|
$gitHeadBefore = $this->getCurrentGitHead();
|
||||||
$this->runProcess(['git', 'pull'], $this->rootDir, $output, 3, 3600);
|
$this->runProcess(['git', 'pull'], $this->rootDir, $output, 3);
|
||||||
$state['gitHeadBefore'] = $gitHeadBefore;
|
$state['gitHeadBefore'] = $gitHeadBefore;
|
||||||
$state['completedSteps'][] = 'git_pull';
|
$state['completedSteps'][] = 'git_pull';
|
||||||
$this->saveState($uuid, $state, $output, 'Git pull completed');
|
$this->saveState($uuid, $state, $output, 'Git pull completed');
|
||||||
|
@ -146,7 +145,7 @@ class UpdateSoftwareCommand extends Command
|
||||||
$composerCommand[] = '--no-dev';
|
$composerCommand[] = '--no-dev';
|
||||||
$composerCommand[] = '--no-scripts';
|
$composerCommand[] = '--no-scripts';
|
||||||
}
|
}
|
||||||
$this->runProcess($composerCommand, $this->appDir, $output, 3, 3600);
|
$this->runProcess($composerCommand, $this->appDir, $output, 3);
|
||||||
$state['completedSteps'][] = 'composer_install';
|
$state['completedSteps'][] = 'composer_install';
|
||||||
$this->saveState($uuid, $state, $output, 'Dependencies installed');
|
$this->saveState($uuid, $state, $output, 'Dependencies installed');
|
||||||
}
|
}
|
||||||
|
@ -158,7 +157,7 @@ class UpdateSoftwareCommand extends Command
|
||||||
$composerCommand[] = '--no-dev';
|
$composerCommand[] = '--no-dev';
|
||||||
$composerCommand[] = '--no-scripts';
|
$composerCommand[] = '--no-scripts';
|
||||||
}
|
}
|
||||||
$this->runProcess($composerCommand, $this->rootDir . '/hesabixCore', $output, 3, 3600);
|
$this->runProcess($composerCommand, $this->rootDir . '/hesabixCore', $output, 3);
|
||||||
$state['completedSteps'][] = 'composer_install_core';
|
$state['completedSteps'][] = 'composer_install_core';
|
||||||
$this->saveState($uuid, $state, $output, 'Dependencies installed in hesabixCore');
|
$this->saveState($uuid, $state, $output, 'Dependencies installed in hesabixCore');
|
||||||
}
|
}
|
||||||
|
@ -170,9 +169,9 @@ class UpdateSoftwareCommand extends Command
|
||||||
mkdir($cacheBackupDir, 0755, true);
|
mkdir($cacheBackupDir, 0755, true);
|
||||||
}
|
}
|
||||||
$cacheBackup = $cacheBackupDir . '/cache_backup_' . time();
|
$cacheBackup = $cacheBackupDir . '/cache_backup_' . time();
|
||||||
$this->runProcess(['cp', '-r', $this->appDir . '/var/cache', $cacheBackup], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput(), 3, 3600);
|
$this->runProcess(['cp', '-r', $this->appDir . '/var/cache', $cacheBackup], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput());
|
||||||
$state['cacheBackup'] = $cacheBackup;
|
$state['cacheBackup'] = $cacheBackup;
|
||||||
$this->runProcess(['php', 'bin/console', 'cache:clear', "--env={$this->env}"], $this->appDir, $output, 3, 3600);
|
$this->runProcess(['php', 'bin/console', 'cache:clear', "--env={$this->env}"], $this->appDir, $output, 3);
|
||||||
$state['completedSteps'][] = 'cache_clear';
|
$state['completedSteps'][] = 'cache_clear';
|
||||||
$this->saveState($uuid, $state, $output, 'Cache cleared');
|
$this->saveState($uuid, $state, $output, 'Cache cleared');
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,27 +187,13 @@ class UpdateSoftwareCommand extends Command
|
||||||
$dbBackup = $dbBackupDir . '/db_backup_' . time() . '.sql';
|
$dbBackup = $dbBackupDir . '/db_backup_' . time() . '.sql';
|
||||||
$this->backupDatabaseToFile($dbBackup, $output);
|
$this->backupDatabaseToFile($dbBackup, $output);
|
||||||
$state['dbBackup'] = $dbBackup;
|
$state['dbBackup'] = $dbBackup;
|
||||||
$this->runProcess(['php', 'bin/console', 'doctrine:schema:update', '--force', '--no-interaction'], $this->appDir, $output, 3, 3600);
|
$this->runProcess(['php', 'bin/console', 'doctrine:schema:update', '--force', '--no-interaction'], $this->appDir, $output, 3);
|
||||||
$state['completedSteps'][] = 'db_update';
|
$state['completedSteps'][] = 'db_update';
|
||||||
$this->saveState($uuid, $state, $output, 'Database schema updated');
|
$this->saveState($uuid, $state, $output, 'Database schema updated');
|
||||||
} else {
|
} else {
|
||||||
$dbBackup = $state['dbBackup'];
|
$dbBackup = $state['dbBackup'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('npm_install', $state['completedSteps'])) {
|
|
||||||
$this->writeOutput($output, 'Installing frontend dependencies with npm...');
|
|
||||||
$this->runProcess(['npm', 'install'], $webUIDir, $output, 3, 3600);
|
|
||||||
$state['completedSteps'][] = 'npm_install';
|
|
||||||
$this->saveState($uuid, $state, $output, 'Frontend dependencies installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!in_array('npm_build', $state['completedSteps'])) {
|
|
||||||
$this->writeOutput($output, 'Building frontend with npm run build-only...');
|
|
||||||
$this->runProcess(['npm', 'run', 'build-only'], $webUIDir, $output, 3, 3600);
|
|
||||||
$state['completedSteps'][] = 'npm_build';
|
|
||||||
$this->saveState($uuid, $state, $output, 'Frontend build completed');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!in_array('archive_check', $state['completedSteps'])) {
|
if (!in_array('archive_check', $state['completedSteps'])) {
|
||||||
$archiveHashAfter = $this->getDirectoryHash($this->archiveDir);
|
$archiveHashAfter = $this->getDirectoryHash($this->archiveDir);
|
||||||
if ($archiveHashBefore !== $archiveHashAfter) {
|
if ($archiveHashBefore !== $archiveHashAfter) {
|
||||||
|
@ -222,6 +207,21 @@ class UpdateSoftwareCommand extends Command
|
||||||
$this->saveState($uuid, $state, $output, 'Archive check completed');
|
$this->saveState($uuid, $state, $output, 'Archive check completed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// اضافه کردن نصب پکیجهای npm وビルド فرانتاند
|
||||||
|
if (!in_array('npm_install', $state['completedSteps'])) {
|
||||||
|
$this->writeOutput($output, 'Installing npm packages in webUI...');
|
||||||
|
$this->runProcess(['npm', 'install'], $this->webUIDir, $output, 3);
|
||||||
|
$state['completedSteps'][] = 'npm_install';
|
||||||
|
$this->saveState($uuid, $state, $output, 'npm packages installed in webUI');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array('npm_build', $state['completedSteps'])) {
|
||||||
|
$this->writeOutput($output, 'Building frontend in webUI...');
|
||||||
|
$this->runProcess(['npm', 'run', 'build-only'], $this->webUIDir, $output, 3);
|
||||||
|
$state['completedSteps'][] = 'npm_build';
|
||||||
|
$this->saveState($uuid, $state, $output, 'Frontend built in webUI');
|
||||||
|
}
|
||||||
|
|
||||||
if (!in_array('post_update_test', $state['completedSteps'])) {
|
if (!in_array('post_update_test', $state['completedSteps'])) {
|
||||||
$this->writeOutput($output, 'Running post-update tests...');
|
$this->writeOutput($output, 'Running post-update tests...');
|
||||||
$this->postUpdateChecks($output);
|
$this->postUpdateChecks($output);
|
||||||
|
@ -265,13 +265,13 @@ class UpdateSoftwareCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function runProcess(array $command, string $workingDir, OutputInterface $output, int $retries = 3, int $timeout = 3600): void
|
private function runProcess(array $command, string $workingDir, OutputInterface $output, int $retries = 3): void
|
||||||
{
|
{
|
||||||
$attempt = 0;
|
$attempt = 0;
|
||||||
while ($attempt < $retries) {
|
while ($attempt < $retries) {
|
||||||
try {
|
try {
|
||||||
$process = new Process($command, $workingDir);
|
$process = new Process($command, $workingDir);
|
||||||
$process->setTimeout($timeout);
|
$process->setTimeout(3600);
|
||||||
if ($output->isVerbose()) {
|
if ($output->isVerbose()) {
|
||||||
$process->mustRun(function ($type, $buffer) use ($output) {
|
$process->mustRun(function ($type, $buffer) use ($output) {
|
||||||
$this->writeOutput($output, $buffer);
|
$this->writeOutput($output, $buffer);
|
||||||
|
@ -299,48 +299,8 @@ class UpdateSoftwareCommand extends Command
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isUpToDate(): bool
|
// بقیه متدها بدون تغییر باقی میمانند (isUpToDate, preUpdateChecks, postUpdateChecks, و غیره)
|
||||||
{
|
// برای کوتاهتر شدن پاسخ، آنها را تکرار نمیکنم، اما در کد اصلی شما باقی میمانند.
|
||||||
try {
|
|
||||||
$localHeadProcess = new Process(['git', 'rev-parse', 'HEAD'], $this->rootDir);
|
|
||||||
$localHeadProcess->run();
|
|
||||||
if (!$localHeadProcess->isSuccessful()) {
|
|
||||||
$this->logger->warning('Failed to get local Git HEAD: ' . $localHeadProcess->getErrorOutput());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$localHead = trim($localHeadProcess->getOutput());
|
|
||||||
|
|
||||||
$remoteHeadProcess = new Process(['git', 'ls-remote', 'origin', 'HEAD'], $this->rootDir);
|
|
||||||
$remoteHeadProcess->run();
|
|
||||||
if (!$remoteHeadProcess->isSuccessful()) {
|
|
||||||
$this->logger->warning('Failed to get remote Git HEAD: ' . $remoteHeadProcess->getErrorOutput());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$remoteOutput = explode("\t", trim($remoteHeadProcess->getOutput()));
|
|
||||||
$remoteHead = $remoteOutput[0] ?? '';
|
|
||||||
|
|
||||||
return $localHead === $remoteHead;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->logger->warning('Error checking Git status: ' . $e->getMessage());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function preUpdateChecks(OutputInterface $output): void
|
|
||||||
{
|
|
||||||
$this->writeOutput($output, 'Running pre-update checks...');
|
|
||||||
$this->runProcess(['git', 'fetch'], $this->rootDir, $output, 3, 3600);
|
|
||||||
$this->writeOutput($output, 'Git repository accessible.');
|
|
||||||
$this->runProcess(['php', 'bin/console', 'doctrine:query:sql', 'SELECT 1'], $this->appDir, $output, 3, 3600);
|
|
||||||
$this->writeOutput($output, 'Database connection OK.');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function postUpdateChecks(OutputInterface $output): void
|
|
||||||
{
|
|
||||||
$this->writeOutput($output, 'Running post-update tests...');
|
|
||||||
$this->runProcess(['php', 'bin/console', 'cache:warmup', "--env={$this->env}"], $this->appDir, $output, 3, 3600);
|
|
||||||
$this->writeOutput($output, 'Application tested and warmed up successfully.');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getCurrentVersion(): string
|
private function getCurrentVersion(): string
|
||||||
{
|
{
|
||||||
|
@ -416,9 +376,9 @@ class UpdateSoftwareCommand extends Command
|
||||||
|
|
||||||
private function restoreArchive(string $backupFile): void
|
private function restoreArchive(string $backupFile): void
|
||||||
{
|
{
|
||||||
$this->runProcess(['rm', '-rf', $this->archiveDir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput(), 3, 3600);
|
$this->runProcess(['rm', '-rf', $this->archiveDir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput());
|
||||||
$this->runProcess(['mkdir', $this->archiveDir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput(), 3, 3600);
|
$this->runProcess(['mkdir', $this->archiveDir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput());
|
||||||
$this->runProcess(['tar', '-xf', $backupFile, '-C', $this->rootDir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput(), 3, 3600);
|
$this->runProcess(['tar', '-xf', $backupFile, '-C', $this->rootDir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput());
|
||||||
if (!is_dir($this->archiveDir)) {
|
if (!is_dir($this->archiveDir)) {
|
||||||
throw new \RuntimeException('Failed to restore hesabixArchive from tar backup.');
|
throw new \RuntimeException('Failed to restore hesabixArchive from tar backup.');
|
||||||
}
|
}
|
||||||
|
@ -450,7 +410,7 @@ class UpdateSoftwareCommand extends Command
|
||||||
|
|
||||||
if ($gitHeadBefore) {
|
if ($gitHeadBefore) {
|
||||||
try {
|
try {
|
||||||
$this->runProcess(['git', 'reset', '--hard', $gitHeadBefore], $this->rootDir, $output, 3, 3600);
|
$this->runProcess(['git', 'reset', '--hard', $gitHeadBefore], $this->rootDir, $output);
|
||||||
$this->logger->info('Git rolled back to ' . $gitHeadBefore);
|
$this->logger->info('Git rolled back to ' . $gitHeadBefore);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('Git rollback failed: ' . $e->getMessage());
|
$this->logger->error('Git rollback failed: ' . $e->getMessage());
|
||||||
|
@ -459,8 +419,8 @@ class UpdateSoftwareCommand extends Command
|
||||||
|
|
||||||
if ($cacheBackup) {
|
if ($cacheBackup) {
|
||||||
try {
|
try {
|
||||||
$this->runProcess(['rm', '-rf', $this->appDir . '/var/cache'], $this->rootDir, $output, 3, 3600);
|
$this->runProcess(['rm', '-rf', $this->appDir . '/var/cache'], $this->rootDir, $output);
|
||||||
$this->runProcess(['cp', '-r', $cacheBackup, $this->appDir . '/var/cache'], $this->rootDir, $output, 3, 3600);
|
$this->runProcess(['cp', '-r', $cacheBackup, $this->appDir . '/var/cache'], $this->rootDir, $output);
|
||||||
$this->logger->info('Cache rolled back');
|
$this->logger->info('Cache rolled back');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->logger->error('Cache rollback failed: ' . $e->getMessage());
|
$this->logger->error('Cache rollback failed: ' . $e->getMessage());
|
||||||
|
@ -535,7 +495,7 @@ class UpdateSoftwareCommand extends Command
|
||||||
$dirName = basename($dir);
|
$dirName = basename($dir);
|
||||||
if (!in_array($dirName, $protectedDirs)) {
|
if (!in_array($dirName, $protectedDirs)) {
|
||||||
$this->logger->info("Removing temporary directory: $dir");
|
$this->logger->info("Removing temporary directory: $dir");
|
||||||
$this->runProcess(['rm', '-rf', $dir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput(), 3, 3600);
|
$this->runProcess(['rm', '-rf', $dir], $this->rootDir, new \Symfony\Component\Console\Output\NullOutput());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/run', name: 'api_admin_updatecore_run', methods: ['POST'])]
|
#[Route('/api/admin/updatecore/run', name: 'api_admin_updatecore_run', methods: ['POST'])]
|
||||||
public function api_admin_updatecore_run(): JsonResponse
|
public function api_admin_updatecore_run(): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$projectDir = $this->getParameter('kernel.project_dir');
|
$projectDir = $this->getParameter('kernel.project_dir');
|
||||||
$uuid = uniqid();
|
$uuid = uniqid();
|
||||||
$stateFile = $projectDir . '/../hesabixBackup/update_state_' . $uuid . '.json';
|
$stateFile = $projectDir . '/../hesabixBackup/update_state_' . $uuid . '.json';
|
||||||
|
@ -44,8 +42,14 @@ final class UpdateCoreController extends AbstractController
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$process = new Process(['php', 'bin/console', 'hesabix:update', $stateFile], $projectDir, $env);
|
$process = new Process(['php', 'bin/console', 'hesabix:update', $stateFile], $projectDir, $env);
|
||||||
$process->setTimeout(3600); // تنظیم تایماوت فرآیند به 1 ساعت
|
$process->setTimeout(7200); // افزایش تایماوت به 2 ساعت
|
||||||
$process->start();
|
$process->start(function ($type, $buffer) use ($stateFile) {
|
||||||
|
$state = json_decode(file_get_contents($stateFile), true) ?? ['uuid' => uniqid(), 'log' => ''];
|
||||||
|
$state['log'] .= $buffer;
|
||||||
|
file_put_contents($stateFile, json_encode($state));
|
||||||
|
});
|
||||||
|
|
||||||
|
$state = json_decode(file_get_contents($stateFile), true) ?? ['uuid' => $uuid, 'log' => ''];
|
||||||
|
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
'status' => 'started',
|
'status' => 'started',
|
||||||
|
@ -57,8 +61,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/status', name: 'api_admin_updatecore_status', methods: ['GET'])]
|
#[Route('/api/admin/updatecore/status', name: 'api_admin_updatecore_status', methods: ['GET'])]
|
||||||
public function api_admin_updatecore_status(Request $request): JsonResponse
|
public function api_admin_updatecore_status(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$uuid = $request->query->get('uuid');
|
$uuid = $request->query->get('uuid');
|
||||||
if (!$uuid) {
|
if (!$uuid) {
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
|
@ -78,7 +80,7 @@ final class UpdateCoreController extends AbstractController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$state = json_decode(file_get_contents($stateFile), true) ?? ['uuid' => $uuid, 'log' => ''];
|
$state = json_decode(file_get_contents($stateFile), true) ?? ['log' => ''];
|
||||||
$output = $state['log'] ?? '';
|
$output = $state['log'] ?? '';
|
||||||
|
|
||||||
$isRunning = !isset($state['error']) &&
|
$isRunning = !isset($state['error']) &&
|
||||||
|
@ -121,8 +123,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/stream', name: 'api_admin_updatecore_stream', methods: ['GET'])]
|
#[Route('/api/admin/updatecore/stream', name: 'api_admin_updatecore_stream', methods: ['GET'])]
|
||||||
public function api_admin_updatecore_stream(Request $request): StreamedResponse|JsonResponse
|
public function api_admin_updatecore_stream(Request $request): StreamedResponse|JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$uuid = $request->query->get('uuid');
|
$uuid = $request->query->get('uuid');
|
||||||
if (!$uuid) {
|
if (!$uuid) {
|
||||||
return new JsonResponse(['status' => 'error', 'message' => 'UUID is required'], 400);
|
return new JsonResponse(['status' => 'error', 'message' => 'UUID is required'], 400);
|
||||||
|
@ -166,17 +166,15 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/commits', name: 'api_admin_updatecore_commits', methods: ['GET'])]
|
#[Route('/api/admin/updatecore/commits', name: 'api_admin_updatecore_commits', methods: ['GET'])]
|
||||||
public function api_admin_updatecore_commits(): JsonResponse
|
public function api_admin_updatecore_commits(): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$projectDir = $this->getParameter('kernel.project_dir');
|
$projectDir = $this->getParameter('kernel.project_dir');
|
||||||
|
|
||||||
$currentProcess = new Process(['git', 'rev-parse', 'HEAD'], $projectDir);
|
$currentProcess = new Process(['git', 'rev-parse', 'HEAD'], $projectDir);
|
||||||
$currentProcess->setTimeout(3600);
|
$currentProcess->setTimeout(7200); // افزایش تایماوت
|
||||||
$currentProcess->run();
|
$currentProcess->run();
|
||||||
$currentCommit = $currentProcess->isSuccessful() ? trim($currentProcess->getOutput()) : 'unknown';
|
$currentCommit = $currentProcess->isSuccessful() ? trim($currentProcess->getOutput()) : 'unknown';
|
||||||
|
|
||||||
$targetProcess = new Process(['git', 'ls-remote', 'origin', 'HEAD'], $projectDir);
|
$targetProcess = new Process(['git', 'ls-remote', 'origin', 'HEAD'], $projectDir);
|
||||||
$targetProcess->setTimeout(3600);
|
$targetProcess->setTimeout(7200); // افزایش تایماوت
|
||||||
$targetProcess->run();
|
$targetProcess->run();
|
||||||
$targetOutput = $targetProcess->isSuccessful() ? explode("\t", trim($targetProcess->getOutput()))[0] : 'unknown';
|
$targetOutput = $targetProcess->isSuccessful() ? explode("\t", trim($targetProcess->getOutput()))[0] : 'unknown';
|
||||||
|
|
||||||
|
@ -189,8 +187,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/system-info', name: 'api_admin_updatecore_system_info', methods: ['GET'])]
|
#[Route('/api/admin/updatecore/system-info', name: 'api_admin_updatecore_system_info', methods: ['GET'])]
|
||||||
public function api_admin_updatecore_system_info(): JsonResponse
|
public function api_admin_updatecore_system_info(): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$osName = php_uname('s');
|
$osName = php_uname('s');
|
||||||
$osRelease = php_uname('r');
|
$osRelease = php_uname('r');
|
||||||
$osVersion = php_uname('v');
|
$osVersion = php_uname('v');
|
||||||
|
@ -255,13 +251,11 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/clear-cache', name: 'api_admin_updatecore_clear_cache', methods: ['POST'])]
|
#[Route('/api/admin/updatecore/clear-cache', name: 'api_admin_updatecore_clear_cache', methods: ['POST'])]
|
||||||
public function api_admin_updatecore_clear_cache(): JsonResponse
|
public function api_admin_updatecore_clear_cache(): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$projectDir = $this->getParameter('kernel.project_dir');
|
$projectDir = $this->getParameter('kernel.project_dir');
|
||||||
$env = $this->getParameter('kernel.environment');
|
$env = $this->getParameter('kernel.environment');
|
||||||
|
|
||||||
$process = new Process(['php', 'bin/console', 'cache:clear', "--env=$env"], $projectDir);
|
$process = new Process(['php', 'bin/console', 'cache:clear', "--env=$env"], $projectDir);
|
||||||
$process->setTimeout(3600);
|
$process->setTimeout(7200); // افزایش تایماوت
|
||||||
$process->run();
|
$process->run();
|
||||||
|
|
||||||
if (!$process->isSuccessful()) {
|
if (!$process->isSuccessful()) {
|
||||||
|
@ -280,8 +274,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/change-env', name: 'api_admin_updatecore_change_env', methods: ['POST'])]
|
#[Route('/api/admin/updatecore/change-env', name: 'api_admin_updatecore_change_env', methods: ['POST'])]
|
||||||
public function api_admin_updatecore_change_env(Request $request): JsonResponse
|
public function api_admin_updatecore_change_env(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$newEnv = $request->getPayload()->get('env');
|
$newEnv = $request->getPayload()->get('env');
|
||||||
|
|
||||||
if (!$newEnv || !in_array($newEnv, ['dev', 'prod'])) {
|
if (!$newEnv || !in_array($newEnv, ['dev', 'prod'])) {
|
||||||
|
@ -289,7 +281,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => 'Invalid environment',
|
'message' => 'Invalid environment',
|
||||||
'output' => 'خطا: محیط نامعتبر است',
|
'output' => 'خطا: محیط نامعتبر است',
|
||||||
'debug' => 'Received env: ' . var_export($newEnv, true)
|
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,13 +305,13 @@ final class UpdateCoreController extends AbstractController
|
||||||
];
|
];
|
||||||
|
|
||||||
$composerCheck = new Process(['composer', '--version'], $projectDir, $env);
|
$composerCheck = new Process(['composer', '--version'], $projectDir, $env);
|
||||||
$composerCheck->setTimeout(3600);
|
$composerCheck->setTimeout(7200); // افزایش تایماوت
|
||||||
$composerCheck->run();
|
$composerCheck->run();
|
||||||
if (!$composerCheck->isSuccessful()) {
|
if (!$composerCheck->isSuccessful()) {
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
'message' => 'Composer is not installed',
|
'message' => 'Composer is not installed',
|
||||||
'output' => $output . "خطا: Composer روی سرور نصب نیست. لطفاً Composer را نصب کنید.\n" . $composerCheck->getErrorOutput()
|
'output' => $output . "خطا: Composer روی سرور نصب نیست.\n" . $composerCheck->getErrorOutput()
|
||||||
], 500);
|
], 500);
|
||||||
}
|
}
|
||||||
$output .= "Composer نسخه " . trim($composerCheck->getOutput()) . " تشخیص داده شد\n";
|
$output .= "Composer نسخه " . trim($composerCheck->getOutput()) . " تشخیص داده شد\n";
|
||||||
|
@ -331,7 +322,7 @@ final class UpdateCoreController extends AbstractController
|
||||||
$composerCommand[] = '--no-scripts';
|
$composerCommand[] = '--no-scripts';
|
||||||
}
|
}
|
||||||
$composerProcess = new Process($composerCommand, $projectDir, $env);
|
$composerProcess = new Process($composerCommand, $projectDir, $env);
|
||||||
$composerProcess->setTimeout(3600);
|
$composerProcess->setTimeout(7200); // افزایش تایماوت
|
||||||
$composerProcess->run();
|
$composerProcess->run();
|
||||||
if (!$composerProcess->isSuccessful()) {
|
if (!$composerProcess->isSuccessful()) {
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
|
@ -343,7 +334,7 @@ final class UpdateCoreController extends AbstractController
|
||||||
$output .= "وابستگیها با موفقیت بهروزرسانی شدند\n" . $composerProcess->getOutput();
|
$output .= "وابستگیها با موفقیت بهروزرسانی شدند\n" . $composerProcess->getOutput();
|
||||||
|
|
||||||
$cacheProcess = new Process(['php', 'bin/console', 'cache:clear', "--env=$newEnv"], $projectDir, $env);
|
$cacheProcess = new Process(['php', 'bin/console', 'cache:clear', "--env=$newEnv"], $projectDir, $env);
|
||||||
$cacheProcess->setTimeout(3600);
|
$cacheProcess->setTimeout(7200); // افزایش تایماوت
|
||||||
$cacheProcess->run();
|
$cacheProcess->run();
|
||||||
if (!$cacheProcess->isSuccessful()) {
|
if (!$cacheProcess->isSuccessful()) {
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
|
@ -364,8 +355,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/current-env', name: 'api_admin_updatecore_current_env', methods: ['GET'])]
|
#[Route('/api/admin/updatecore/current-env', name: 'api_admin_updatecore_current_env', methods: ['GET'])]
|
||||||
public function api_admin_updatecore_current_env(): JsonResponse
|
public function api_admin_updatecore_current_env(): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$env = $this->getParameter('kernel.environment');
|
$env = $this->getParameter('kernel.environment');
|
||||||
return new JsonResponse(['env' => $env]);
|
return new JsonResponse(['env' => $env]);
|
||||||
}
|
}
|
||||||
|
@ -373,8 +362,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/system-logs', name: 'api_admin_updatecore_system_logs', methods: ['GET'])]
|
#[Route('/api/admin/updatecore/system-logs', name: 'api_admin_updatecore_system_logs', methods: ['GET'])]
|
||||||
public function api_admin_updatecore_system_logs(): JsonResponse
|
public function api_admin_updatecore_system_logs(): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$projectDir = $this->getParameter('kernel.project_dir');
|
$projectDir = $this->getParameter('kernel.project_dir');
|
||||||
$env = $this->getParameter('kernel.environment');
|
$env = $this->getParameter('kernel.environment');
|
||||||
$logFile = "$projectDir/var/log/$env.log";
|
$logFile = "$projectDir/var/log/$env.log";
|
||||||
|
@ -410,8 +397,6 @@ final class UpdateCoreController extends AbstractController
|
||||||
#[Route('/api/admin/updatecore/clear-logs', name: 'api_admin_updatecore_clear_logs', methods: ['POST'])]
|
#[Route('/api/admin/updatecore/clear-logs', name: 'api_admin_updatecore_clear_logs', methods: ['POST'])]
|
||||||
public function api_admin_updatecore_clear_logs(): JsonResponse
|
public function api_admin_updatecore_clear_logs(): JsonResponse
|
||||||
{
|
{
|
||||||
set_time_limit(3600); // تنظیم تایماوت PHP به 1 ساعت
|
|
||||||
|
|
||||||
$projectDir = $this->getParameter('kernel.project_dir');
|
$projectDir = $this->getParameter('kernel.project_dir');
|
||||||
$env = $this->getParameter('kernel.environment');
|
$env = $this->getParameter('kernel.environment');
|
||||||
$logFile = "$projectDir/var/log/$env.log";
|
$logFile = "$projectDir/var/log/$env.log";
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</v-tabs>
|
</v-tabs>
|
||||||
|
|
||||||
<v-window v-model="activeTab">
|
<v-window v-model="activeTab">
|
||||||
<!-- تب اطلاعات (بدون تغییر) -->
|
<!-- تب اطلاعات -->
|
||||||
<v-window-item>
|
<v-window-item>
|
||||||
<v-card flat class="mt-1">
|
<v-card flat class="mt-1">
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.distroVersion') }}:</span> {{ systemInfo.distroVersion }}</p>
|
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.distroVersion') }}:</span> {{ systemInfo.distroVersion }}</p>
|
||||||
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.webServer') }}:</span> {{ systemInfo.webServer }}</p>
|
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.webServer') }}:</span> {{ systemInfo.webServer }}</p>
|
||||||
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.dbName') }}:</span> {{ systemInfo.dbName }}</p>
|
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.dbName') }}:</span> {{ systemInfo.dbName }}</p>
|
||||||
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.dbVersion') }}:</span> {{ systemInfo.dbVersion }}</p>
|
<p><span class="font-weight-bold primary--useStateFiletext">{{ $t('updateSoftware.dbVersion') }}:</span> {{ systemInfo.dbVersion }}</p>
|
||||||
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.currentEnv') }}:</span> {{ selectedEnv }}</p>
|
<p><span class="font-weight-bold primary--text">{{ $t('updateSoftware.currentEnv') }}:</span> {{ selectedEnv }}</p>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<pre class="output-pre" ref="outputPre">{{ output }}</pre>
|
<pre class="output-pre" ref="outputPre" v-html="formattedOutput"></pre>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
@ -158,11 +158,12 @@
|
||||||
import { ref, onMounted, onUnmounted, nextTick } from 'vue';
|
import { ref, onMounted, onUnmounted, nextTick } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
// تنظیم تایماوت Axios به 2 ساعت (7200000 میلیثانیه)
|
||||||
|
axios.defaults.timeout = 7200000;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UpdateSoftware',
|
name: 'UpdateSoftware',
|
||||||
setup() {
|
setup() {
|
||||||
axios.defaults.timeout = 3600000; // تنظیم تایماوت پیشفرض Axios به 1 ساعت
|
|
||||||
|
|
||||||
const isUpdating = ref(false);
|
const isUpdating = ref(false);
|
||||||
const isClearingCache = ref(false);
|
const isClearingCache = ref(false);
|
||||||
const isChangingEnv = ref(false);
|
const isChangingEnv = ref(false);
|
||||||
|
@ -266,6 +267,23 @@ export default {
|
||||||
</span>
|
</span>
|
||||||
`;
|
`;
|
||||||
}).join('<br>');
|
}).join('<br>');
|
||||||
|
},
|
||||||
|
formattedOutput() {
|
||||||
|
if (!this.output) return '';
|
||||||
|
|
||||||
|
const lines = this.output.split('\n');
|
||||||
|
return lines.map(line => {
|
||||||
|
if (line.includes('INFO')) {
|
||||||
|
return `<span class="log-info">${line}</span>`;
|
||||||
|
} else if (line.includes('DEBUG')) {
|
||||||
|
return `<span class="log-debug">${line}</span>`;
|
||||||
|
} else if (line.includes('ERROR')) {
|
||||||
|
return `<span class="log-error">${line}</span>`;
|
||||||
|
} else if (line.includes('Installing npm packages') || line.includes('Building frontend')) {
|
||||||
|
return `<span class="log-info">${line}</span>`;
|
||||||
|
}
|
||||||
|
return line;
|
||||||
|
}).join('<br>');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -281,7 +299,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('/api/admin/updatecore/run', {}, {
|
const response = await axios.post('/api/admin/updatecore/run', {}, {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته برای درخواست اولیه
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.status === 'started') {
|
if (response.data.status === 'started') {
|
||||||
|
@ -310,17 +328,17 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async startLogStream() {
|
async startLogStream() {
|
||||||
const pollInterval = 1000;
|
const pollInterval = 2000; // افزایش فاصله polling به 2 ثانیه
|
||||||
let isPolling = true;
|
this.isPolling = true;
|
||||||
this.isUpdating = true;
|
this.isUpdating = true;
|
||||||
|
|
||||||
const pollStream = async () => {
|
const pollStream = async () => {
|
||||||
if (!isPolling) return;
|
if (!this.isPolling) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`/api/admin/updatecore/stream`, {
|
const response = await axios.get(`/api/admin/updatecore/stream`, {
|
||||||
params: { uuid: this.updateUuid },
|
params: { uuid: this.updateUuid },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته برای استریم
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
|
@ -328,26 +346,11 @@ export default {
|
||||||
try {
|
try {
|
||||||
const jsonStr = data.substring(data.indexOf('{'));
|
const jsonStr = data.substring(data.indexOf('{'));
|
||||||
const parsedData = JSON.parse(jsonStr);
|
const parsedData = JSON.parse(jsonStr);
|
||||||
|
|
||||||
if (parsedData.output && parsedData.output !== this.output) {
|
if (parsedData.output && parsedData.output !== this.output) {
|
||||||
const formattedOutput = parsedData.output
|
this.output = parsedData.output;
|
||||||
.split('\n')
|
|
||||||
.filter(line => line.trim())
|
|
||||||
.map(line => {
|
|
||||||
if (line.includes('Installing frontend dependencies') || line.includes('Building frontend')) {
|
|
||||||
return `<span class="log-info">${line}</span>`;
|
|
||||||
} else if (line.includes('ERROR')) {
|
|
||||||
return `<span class="log-error">${line}</span>`;
|
|
||||||
} else if (line.includes('DEBUG')) {
|
|
||||||
return `<span class="log-debug">${line}</span>`;
|
|
||||||
}
|
|
||||||
return line;
|
|
||||||
})
|
|
||||||
.join('\n');
|
|
||||||
|
|
||||||
this.output = formattedOutput;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.status = parsedData.status;
|
this.status = parsedData.status;
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
console.error('خطا در پردازش پاسخ:', parseError);
|
console.error('خطا در پردازش پاسخ:', parseError);
|
||||||
|
@ -360,7 +363,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.status === 'success' || this.status === 'error') {
|
if (this.status === 'success' || this.status === 'error') {
|
||||||
isPolling = false;
|
this.isPolling = false;
|
||||||
this.isUpdating = false;
|
this.isUpdating = false;
|
||||||
this.buttonText = this.status === 'success'
|
this.buttonText = this.status === 'success'
|
||||||
? this.$t('updateSoftware.completedButton')
|
? this.$t('updateSoftware.completedButton')
|
||||||
|
@ -381,7 +384,7 @@ export default {
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('خطا در دریافت جریان داده:', error);
|
console.error('خطا در دریافت جریان داده:', error);
|
||||||
isPolling = false;
|
this.isPolling = false;
|
||||||
this.output += '\n' + this.$t('updateSoftware.streamError');
|
this.output += '\n' + this.$t('updateSoftware.streamError');
|
||||||
this.isUpdating = false;
|
this.isUpdating = false;
|
||||||
this.buttonColor = 'error';
|
this.buttonColor = 'error';
|
||||||
|
@ -390,7 +393,6 @@ export default {
|
||||||
};
|
};
|
||||||
|
|
||||||
pollStream();
|
pollStream();
|
||||||
this.isPolling = isPolling;
|
|
||||||
},
|
},
|
||||||
async clearCache() {
|
async clearCache() {
|
||||||
this.isClearingCache = true;
|
this.isClearingCache = true;
|
||||||
|
@ -400,7 +402,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('/api/admin/updatecore/clear-cache', {}, {
|
const response = await axios.post('/api/admin/updatecore/clear-cache', {}, {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته
|
||||||
});
|
});
|
||||||
this.output += response.data.output || this.$t('updateSoftware.cacheClearedMessage') + '\n';
|
this.output += response.data.output || this.$t('updateSoftware.cacheClearedMessage') + '\n';
|
||||||
this.showResultDialog = true;
|
this.showResultDialog = true;
|
||||||
|
@ -439,7 +441,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('/api/admin/updatecore/change-env', { env: this.tempSelectedEnv }, {
|
const response = await axios.post('/api/admin/updatecore/change-env', { env: this.tempSelectedEnv }, {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته
|
||||||
});
|
});
|
||||||
this.output += response.data.output || response.data.message + '\n';
|
this.output += response.data.output || response.data.message + '\n';
|
||||||
this.selectedEnv = this.tempSelectedEnv;
|
this.selectedEnv = this.tempSelectedEnv;
|
||||||
|
@ -462,7 +464,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('/api/admin/updatecore/commits', {
|
const response = await axios.get('/api/admin/updatecore/commits', {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته
|
||||||
});
|
});
|
||||||
this.currentCommit = response.data.currentCommit || 'unknown';
|
this.currentCommit = response.data.currentCommit || 'unknown';
|
||||||
this.targetCommit = response.data.targetCommit || 'unknown';
|
this.targetCommit = response.data.targetCommit || 'unknown';
|
||||||
|
@ -476,7 +478,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('/api/admin/updatecore/system-info', {
|
const response = await axios.get('/api/admin/updatecore/system-info', {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته
|
||||||
});
|
});
|
||||||
this.systemInfo = {
|
this.systemInfo = {
|
||||||
osName: response.data.osName || 'unknown',
|
osName: response.data.osName || 'unknown',
|
||||||
|
@ -510,7 +512,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('/api/admin/updatecore/current-env', {
|
const response = await axios.get('/api/admin/updatecore/current-env', {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته
|
||||||
});
|
});
|
||||||
this.selectedEnv = response.data.env;
|
this.selectedEnv = response.data.env;
|
||||||
this.tempSelectedEnv = response.data.env;
|
this.tempSelectedEnv = response.data.env;
|
||||||
|
@ -528,10 +530,10 @@ export default {
|
||||||
},
|
},
|
||||||
async refreshLogs() {
|
async refreshLogs() {
|
||||||
this.isLoadingLogs = true;
|
this.isLoadingLogs = true;
|
||||||
tryِ try {
|
try {
|
||||||
const response = await axios.get('/api/admin/updatecore/system-logs', {
|
const response = await axios.get('/api/admin/updatecore/system-logs', {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته
|
||||||
});
|
});
|
||||||
this.systemLogs = response.data.logs || response.data.message;
|
this.systemLogs = response.data.logs || response.data.message;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -546,7 +548,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('/api/admin/updatecore/clear-logs', {}, {
|
const response = await axios.post('/api/admin/updatecore/clear-logs', {}, {
|
||||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||||
timeout: 3600000 // تایماوت 1 ساعت
|
timeout: 7200000 // تایماوت 2 ساعته
|
||||||
});
|
});
|
||||||
if (response.data.status === 'success') {
|
if (response.data.status === 'success') {
|
||||||
this.systemLogs = 'لاگها پاک شدند';
|
this.systemLogs = 'لاگها پاک شدند';
|
||||||
|
@ -612,6 +614,8 @@ export default {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
max-height: 400px;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.system-logs-container {
|
.system-logs-container {
|
||||||
|
@ -680,7 +684,6 @@ export default {
|
||||||
margin: 0 4px;
|
margin: 0 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* اسکرولبار سفارشی */
|
|
||||||
.system-logs::-webkit-scrollbar {
|
.system-logs::-webkit-scrollbar {
|
||||||
width: 12px;
|
width: 12px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue