feat: implement PortMappingService and add dynamic PHP configuration template with IPC handlers
This commit is contained in:
@@ -11,9 +11,9 @@ disable_functions =
|
||||
disable_classes =
|
||||
zend.enable_gc = On
|
||||
expose_php = On
|
||||
max_execution_time = 30
|
||||
max_input_time = 60
|
||||
memory_limit = 128M
|
||||
max_execution_time = 300
|
||||
max_input_time = 120
|
||||
memory_limit = 512M
|
||||
error_reporting = E_ALL
|
||||
display_errors = On
|
||||
display_startup_errors = On
|
||||
@@ -27,7 +27,7 @@ variables_order = "GPCS"
|
||||
request_order = "GP"
|
||||
register_argc_argv = Off
|
||||
auto_globals_jit = On
|
||||
post_max_size = 8M
|
||||
post_max_size = 100M
|
||||
auto_prepend_file =
|
||||
auto_append_file =
|
||||
default_mimetype = "text/html"
|
||||
@@ -36,7 +36,7 @@ doc_root =
|
||||
user_dir =
|
||||
enable_dl = Off
|
||||
file_uploads = On
|
||||
upload_max_filesize = 2M
|
||||
upload_max_filesize = 100M
|
||||
max_file_uploads = 20
|
||||
allow_url_fopen = On
|
||||
allow_url_include = Off
|
||||
|
||||
+20
-5
@@ -212,7 +212,11 @@ export function registerIpcHandlers(): void {
|
||||
|
||||
const isWindows = process.platform === 'win32';
|
||||
const dbBinary = isWindows ? 'mariadbd.exe' : 'mariadbd';
|
||||
const installBinary = isWindows ? 'mariadb-install-db.exe' : 'mariadb-install-db';
|
||||
const mysqlInstallBinary = isWindows ? 'mysql_install_db.exe' : 'mysql_install_db';
|
||||
|
||||
let binPath = findExecutable(dbBinDir, dbBinary) || findExecutable(dbBinDir, isWindows ? 'mysqld.exe' : 'mysqld');
|
||||
let installPath = findExecutable(dbBinDir, installBinary) || findExecutable(dbBinDir, mysqlInstallBinary);
|
||||
|
||||
if (!binPath) return { success: false, message: 'MariaDB executable bulunamadı. Lütfen indirin.' }
|
||||
|
||||
@@ -226,16 +230,27 @@ export function registerIpcHandlers(): void {
|
||||
// Also kill anything else listening on the same port
|
||||
await processManager.killByPort(serviceName, dbPort)
|
||||
|
||||
// Initialize if data directory is empty
|
||||
if (!fs.existsSync(dataDir) || fs.readdirSync(dataDir).length === 0) {
|
||||
// Initialize if data directory is empty or missing system tables
|
||||
const systemDbDir = path.join(dataDir, 'mysql')
|
||||
if (!fs.existsSync(dataDir) || fs.readdirSync(dataDir).length === 0 || !fs.existsSync(systemDbDir)) {
|
||||
if (!fs.existsSync(dataDir)) fs.mkdirSync(dataDir, { recursive: true })
|
||||
console.log(`Initializing MariaDB data directory for ${serviceName}...`)
|
||||
|
||||
try {
|
||||
// Try MariaDB/Modern MySQL initialization first (5.7+/10.x+)
|
||||
await processManager.runOnce(binPath, ['--initialize-insecure', `--datadir=${dataDir.replace(/\\/g, '/')}`])
|
||||
const normalizedDataDir = dataDir.replace(/\\/g, '/')
|
||||
if (installPath) {
|
||||
console.log(`Using install tool: ${installPath}`)
|
||||
// MariaDB specific installation
|
||||
await processManager.runOnce(installPath, [
|
||||
`--datadir=${normalizedDataDir}`
|
||||
])
|
||||
} else {
|
||||
console.log(`Using server init: ${binPath}`)
|
||||
// MySQL 5.7+ / modern MariaDB fallback
|
||||
await processManager.runOnce(binPath, ['--initialize-insecure', `--datadir=${normalizedDataDir}`])
|
||||
}
|
||||
} catch (err) {
|
||||
console.log(`Modern init failed, trying template copy for ${serviceName}...`)
|
||||
console.log(`Initialization tool failed, trying template copy for ${serviceName}...`)
|
||||
// Fallback: Copy default 'data' folder from binary dir if it exists
|
||||
const templateDataDir = path.join(dbBinDir, 'data')
|
||||
if (fs.existsSync(templateDataDir)) {
|
||||
|
||||
@@ -23,9 +23,16 @@ export class PortMappingService {
|
||||
try {
|
||||
this.portMap = JSON.parse(fs.readFileSync(this.configFile, 'utf-8'))
|
||||
|
||||
const phpPorts = Object.values(this.portMap.php)
|
||||
const phpPorts = Object.values(this.portMap.php || {})
|
||||
if (phpPorts.length > 0) this.nextPhpPort = Math.max(...phpPorts) + 1
|
||||
|
||||
// Backward compatibility: switch mysql to mariadb
|
||||
if (!this.portMap.mariadb) {
|
||||
this.portMap.mariadb = (this.portMap as any).mysql || {}
|
||||
delete (this.portMap as any).mysql
|
||||
this.save()
|
||||
}
|
||||
|
||||
const mariaDbPorts = Object.values(this.portMap.mariadb)
|
||||
if (mariaDbPorts.length > 0) this.nextMariaDbPort = Math.max(...mariaDbPorts) + 1
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user