feat: implement IPC handlers for service management and add MySQL configuration template

This commit is contained in:
Ümit Tunç
2026-03-28 16:40:33 +03:00
parent 91b13513fc
commit 86a19567ff
3 changed files with 13 additions and 6 deletions
+1
View File
@@ -1,6 +1,7 @@
[mysqld] [mysqld]
port={{PORT}} port={{PORT}}
datadir="{{DATADIR}}" datadir="{{DATADIR}}"
tmpdir="{{DATADIR}}"
socket="{{SOCKET}}" socket="{{SOCKET}}"
character-set-server=utf8mb4 character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci collation-server=utf8mb4_unicode_ci
+4 -1
View File
@@ -67,7 +67,7 @@ export function registerIpcHandlers(): void {
return { success: false, message: 'Nginx konfigürasyon hatası! Log sekmesini kontrol edin.' } return { success: false, message: 'Nginx konfigürasyon hatası! Log sekmesini kontrol edin.' }
} }
const success = await processManager.startService('nginx', binPath, ['-p', nginxPrefix, '-c', configPath], true) const success = await processManager.startService('nginx', binPath, ['-p', nginxPrefix, '-c', configPath], false)
return { success, message: success ? 'Nginx başlatıldı.' : 'Nginx devreye alınamadı (Hata loglarını kontrol edin).' } return { success, message: success ? 'Nginx başlatıldı.' : 'Nginx devreye alınamadı (Hata loglarını kontrol edin).' }
} }
@@ -90,6 +90,9 @@ export function registerIpcHandlers(): void {
if (!binPath) return { success: false, message: 'MySQL executable bulunamadı. Lütfen indirin.' } if (!binPath) return { success: false, message: 'MySQL executable bulunamadı. Lütfen indirin.' }
// Force kill any existing instances before starting
await processManager.forceKillAll('mysql')
// Initialize if data directory is empty // Initialize if data directory is empty
if (!fs.existsSync(dataDir) || fs.readdirSync(dataDir).length === 0) { if (!fs.existsSync(dataDir) || fs.readdirSync(dataDir).length === 0) {
if (!fs.existsSync(dataDir)) fs.mkdirSync(dataDir, { recursive: true }) if (!fs.existsSync(dataDir)) fs.mkdirSync(dataDir, { recursive: true })
+8 -5
View File
@@ -1,4 +1,4 @@
import { spawn, ChildProcess, exec } from 'child_process' import { spawn, ChildProcess } from 'child_process'
import path from 'path' import path from 'path'
import { app } from 'electron' import { app } from 'electron'
import fs from 'fs' import fs from 'fs'
@@ -65,7 +65,7 @@ export class ProcessManager {
async runOnce(binPath: string, args: string[], name?: string): Promise<boolean> { async runOnce(binPath: string, args: string[], name?: string): Promise<boolean> {
return new Promise((resolve) => { return new Promise((resolve) => {
const child = spawn(binPath, args, { stdio: 'pipe', shell: true, windowsHide: true }) const child = spawn(binPath, args, { stdio: 'pipe', shell: false, windowsHide: true })
child.stdout?.on('data', (data) => { child.stdout?.on('data', (data) => {
const out = data.toString() const out = data.toString()
@@ -157,10 +157,13 @@ export class ProcessManager {
const executableName = name === 'nginx' ? 'nginx.exe' : name === 'php' ? 'php-cgi.exe' : 'mysqld.exe' const executableName = name === 'nginx' ? 'nginx.exe' : name === 'php' ? 'php-cgi.exe' : 'mysqld.exe'
this.addLog(name, `Force killing all ${executableName} processes...`) this.addLog(name, `Force killing all ${executableName} processes...`)
exec(`taskkill /F /IM ${executableName} /T`, (_err) => { const child = spawn('taskkill', ['/F', '/IM', executableName, '/T'], {
// If it fails, usually it means the process isn't running, which is fine windowsHide: true,
resolve(true) shell: false
}) })
child.on('close', () => resolve(true))
child.on('error', () => resolve(true))
}) })
} }