feat: implement IPC service management handlers for Nginx, PHP, and MySQL and add multi-language support.

This commit is contained in:
Ümit Tunç
2026-03-28 21:47:45 +03:00
parent a411138732
commit 2a66537f86
7 changed files with 178 additions and 88 deletions
+23 -12
View File
@@ -115,32 +115,43 @@ export function registerIpcHandlers(): void {
return { success, message: success ? `${phpVersion || ''} PHP başlatıldı.` : `${phpVersion || ''} PHP devreye alınamadı.` }
}
if (serviceName === 'mysql') {
const dataDir = path.join(app.getPath('userData'), 'mysql_data')
const binPath = findExecutable(binDir, 'mysqld.exe')
if (serviceName.startsWith('mysql')) {
const versionMatch = serviceName.match(/^mysql:(.+)$/)
const mysqlVersion = versionMatch ? versionMatch[1] : null
const mysqlId = mysqlVersion ? `mysql-${mysqlVersion}` : null
const dataDir = mysqlId
? path.join(app.getPath('userData'), `mysql_data_${mysqlId}`)
: path.join(app.getPath('userData'), 'mysql_data')
const mysqlDir = mysqlId ? path.join(binDir, mysqlId) : binDir
const binPath = findExecutable(mysqlDir, 'mysqld.exe')
if (!binPath) return { success: false, message: 'MySQL executable bulunamadı. Lütfen indirin.' }
// Force kill any existing instances before starting
await processManager.forceKillAll('mysql')
// Force kill this specific version if running or generic mysql
// Actually processManager handles by serviceName
await processManager.forceKillAll(serviceName)
// Initialize if data directory is empty
if (!fs.existsSync(dataDir) || fs.readdirSync(dataDir).length === 0) {
if (!fs.existsSync(dataDir)) fs.mkdirSync(dataDir, { recursive: true })
console.log('Initializing MySQL data directory...')
console.log(`Initializing MySQL data directory for ${serviceName}...`)
await processManager.runOnce(binPath, ['--initialize-insecure', `--datadir=${dataDir.replace(/\\/g, '/')}`])
}
const logFile = path.join(app.getPath('userData'), 'logs', 'mysql_error.log')
const configPath = await configService.generateConfig('my.ini.template', 'my.ini', {
PORT: settings.mysqlPort,
const mysqlPort = mysqlId ? (settings.mysqlPorts?.[mysqlId] || '3306') : settings.mysqlPort
const logFile = path.join(app.getPath('userData'), 'logs', `${serviceName}_error.log`)
const configPath = await configService.generateConfig('my.ini.template', `my_${mysqlId || 'default'}.ini`, {
PORT: mysqlPort,
DATADIR: dataDir.replace(/\\/g, '/'),
SOCKET: '/tmp/mysql.sock',
SOCKET: `/tmp/${serviceName}.sock`,
LOG_FILE: logFile.replace(/\\/g, '/')
})
const success = await processManager.startService('mysql', binPath, ['--defaults-file=' + configPath], false)
return { success, message: success ? 'MySQL başlatıldı.' : 'MySQL devreye alınamadı (Hata loglarını kontrol edin).' }
const success = await processManager.startService(serviceName, binPath, ['--defaults-file=' + configPath], false)
return { success, message: success ? `${mysqlVersion || ''} MySQL başlatıldı.` : `${mysqlVersion || ''} MySQL devreye alınamadı.` }
}
return { success: false, message: 'Bilinmeyen servis.' }