perf(backup): extend backup restore and conversion timeout to 1 hour (3600s)

This commit is contained in:
Ray1111-aa
2026-11-03 13:34:07 +07:00
parent 61332f948b
commit a55ead4c5b
5 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -149,7 +149,7 @@ class DatabaseBackupService
*/ */
public function createKmhBackup(?array $selectedTables = null, bool $includeMedia = false, ?string $customFilename = null): string public function createKmhBackup(?array $selectedTables = null, bool $includeMedia = false, ?string $customFilename = null): string
{ {
@set_time_limit(1800); @set_time_limit(3600);
@ini_set('memory_limit', '1024M'); @ini_set('memory_limit', '1024M');
if (!class_exists('ZipArchive')) { if (!class_exists('ZipArchive')) {
@@ -242,7 +242,7 @@ class DatabaseBackupService
*/ */
public function restore(string $backupFilenameOrPath): void public function restore(string $backupFilenameOrPath): void
{ {
@set_time_limit(1800); @set_time_limit(3600);
@ini_set('memory_limit', '1024M'); @ini_set('memory_limit', '1024M');
$filePath = File::exists($backupFilenameOrPath) $filePath = File::exists($backupFilenameOrPath)
+7 -7
View File
@@ -32,7 +32,7 @@ class KmhConverterService
*/ */
public function inspectServerFile(string $filename): array public function inspectServerFile(string $filename): array
{ {
@set_time_limit(1800); @set_time_limit(3600);
@ini_set('memory_limit', '1024M'); @ini_set('memory_limit', '1024M');
$backupDir = $this->backupService->getBackupDirectory(); $backupDir = $this->backupService->getBackupDirectory();
@@ -82,9 +82,9 @@ class KmhConverterService
$tempDir = storage_path('app/temp_converter'); $tempDir = storage_path('app/temp_converter');
File::ensureDirectoryExists($tempDir); File::ensureDirectoryExists($tempDir);
// Bersihkan file sementara yang lebih tua dari 30 menit // Bersihkan file sementara yang lebih tua dari 1 jam (3600 detik)
foreach (File::files($tempDir) as $f) { foreach (File::files($tempDir) as $f) {
if ((time() - $f->getMTime()) > 1800) { if ((time() - $f->getMTime()) > 3600) {
@unlink($f->getPathname()); @unlink($f->getPathname());
} }
} }
@@ -128,7 +128,7 @@ class KmhConverterService
*/ */
public function inspectUploadedFile(UploadedFile $file): array public function inspectUploadedFile(UploadedFile $file): array
{ {
@set_time_limit(1800); @set_time_limit(3600);
@ini_set('memory_limit', '1024M'); @ini_set('memory_limit', '1024M');
$realPath = $file->getRealPath(); $realPath = $file->getRealPath();
@@ -180,9 +180,9 @@ class KmhConverterService
$tempDir = storage_path('app/temp_converter'); $tempDir = storage_path('app/temp_converter');
File::ensureDirectoryExists($tempDir); File::ensureDirectoryExists($tempDir);
// Bersihkan file sementara yang lebih tua dari 30 menit // Bersihkan file sementara yang lebih tua dari 1 jam (3600 detik)
foreach (File::files($tempDir) as $f) { foreach (File::files($tempDir) as $f) {
if ((time() - $f->getMTime()) > 1800) { if ((time() - $f->getMTime()) > 3600) {
@unlink($f->getPathname()); @unlink($f->getPathname());
} }
} }
@@ -259,7 +259,7 @@ class KmhConverterService
*/ */
public function convertKmhFilePath(string $kmhFilePath, string $originalFilename, array $selectedTables, string $format): array public function convertKmhFilePath(string $kmhFilePath, string $originalFilename, array $selectedTables, string $format): array
{ {
@set_time_limit(1800); @set_time_limit(3600);
@ini_set('memory_limit', '1024M'); @ini_set('memory_limit', '1024M');
$format = strtolower($format); $format = strtolower($format);
+6 -6
View File
@@ -10,10 +10,10 @@ server {
client_max_body_size 500M; client_max_body_size 500M;
client_body_buffer_size 1M; client_body_buffer_size 1M;
client_body_timeout 1800s; client_body_timeout 3600s;
client_header_timeout 1800s; client_header_timeout 3600s;
send_timeout 1800s; send_timeout 3600s;
keepalive_timeout 1800s; keepalive_timeout 3600s;
# Security Headers # Security Headers
add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Frame-Options "SAMEORIGIN" always;
@@ -61,8 +61,8 @@ server {
fastcgi_hide_header X-Powered-By; fastcgi_hide_header X-Powered-By;
fastcgi_buffers 16 16k; fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k; fastcgi_buffer_size 32k;
fastcgi_read_timeout 1800; fastcgi_read_timeout 3600;
fastcgi_send_timeout 1800; fastcgi_send_timeout 3600;
} }
location ~ /\.(?!well-known).* { location ~ /\.(?!well-known).* {
+2 -2
View File
@@ -1,7 +1,7 @@
upload_max_filesize = 500M upload_max_filesize = 500M
post_max_size = 500M post_max_size = 500M
memory_limit = 1024M memory_limit = 1024M
max_execution_time = 1800 max_execution_time = 3600
max_input_time = 1800 max_input_time = 3600
date.timezone = Asia/Jakarta date.timezone = Asia/Jakarta
expose_php = Off expose_php = Off
@@ -1019,7 +1019,7 @@
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('POST', form.action, true); xhr.open('POST', form.action, true);
xhr.timeout = 1800000; // 30 Menit timeout untuk berkas backup besar xhr.timeout = 3600000; // 1 Jam timeout untuk berkas backup besar
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.upload.onprogress = function(e) { xhr.upload.onprogress = function(e) {
@@ -1090,7 +1090,7 @@
btn.classList.remove('opacity-75', 'cursor-not-allowed'); btn.classList.remove('opacity-75', 'cursor-not-allowed');
} }
if (text) text.textContent = 'Mulai Pemulihan Sistem'; if (text) text.textContent = 'Mulai Pemulihan Sistem';
document.getElementById('directRestoreErrorMessage').textContent = 'Waktu pengunggahan habis (Timeout 30 Menit). Silakan periksa kestabilan jaringan internet Anda.'; document.getElementById('directRestoreErrorMessage').textContent = 'Waktu pengunggahan habis (Timeout 1 Jam). Silakan periksa kestabilan jaringan internet Anda.';
document.getElementById('directRestoreError').classList.remove('hidden'); document.getElementById('directRestoreError').classList.remove('hidden');
}; };
@@ -1332,7 +1332,7 @@
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('POST', `{{ route('admin.backups.converter.inspect') }}`, true); xhr.open('POST', `{{ route('admin.backups.converter.inspect') }}`, true);
xhr.timeout = 1800000; // 30 Menit timeout xhr.timeout = 3600000; // 1 Jam timeout
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Accept', 'application/json'); xhr.setRequestHeader('Accept', 'application/json');
@@ -1411,7 +1411,7 @@
xhr.ontimeout = function() { xhr.ontimeout = function() {
loading.classList.add('hidden'); loading.classList.add('hidden');
document.getElementById('panelConverterUpload').classList.remove('hidden'); document.getElementById('panelConverterUpload').classList.remove('hidden');
showConverterError('Waktu pengunggahan habis (Timeout 30 Menit). Silakan periksa kestabilan jaringan internet Anda.'); showConverterError('Waktu pengunggahan habis (Timeout 1 Jam). Silakan periksa kestabilan jaringan internet Anda.');
}; };
xhr.send(formData); xhr.send(formData);