feat: implement IPC handlers for service management and add MySQL configuration template
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
[mysqld]
|
||||
port={{PORT}}
|
||||
datadir="{{DATADIR}}"
|
||||
tmpdir="{{DATADIR}}"
|
||||
socket="{{SOCKET}}"
|
||||
character-set-server=utf8mb4
|
||||
collation-server=utf8mb4_unicode_ci
|
||||
|
||||
@@ -67,7 +67,7 @@ export function registerIpcHandlers(): void {
|
||||
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).' }
|
||||
}
|
||||
|
||||
@@ -90,6 +90,9 @@ export function registerIpcHandlers(): void {
|
||||
|
||||
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
|
||||
if (!fs.existsSync(dataDir) || fs.readdirSync(dataDir).length === 0) {
|
||||
if (!fs.existsSync(dataDir)) fs.mkdirSync(dataDir, { recursive: true })
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { spawn, ChildProcess, exec } from 'child_process'
|
||||
import { spawn, ChildProcess } from 'child_process'
|
||||
import path from 'path'
|
||||
import { app } from 'electron'
|
||||
import fs from 'fs'
|
||||
@@ -65,7 +65,7 @@ export class ProcessManager {
|
||||
|
||||
async runOnce(binPath: string, args: string[], name?: string): Promise<boolean> {
|
||||
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) => {
|
||||
const out = data.toString()
|
||||
@@ -157,10 +157,13 @@ export class ProcessManager {
|
||||
const executableName = name === 'nginx' ? 'nginx.exe' : name === 'php' ? 'php-cgi.exe' : 'mysqld.exe'
|
||||
this.addLog(name, `Force killing all ${executableName} processes...`)
|
||||
|
||||
exec(`taskkill /F /IM ${executableName} /T`, (_err) => {
|
||||
// If it fails, usually it means the process isn't running, which is fine
|
||||
resolve(true)
|
||||
const child = spawn('taskkill', ['/F', '/IM', executableName, '/T'], {
|
||||
windowsHide: true,
|
||||
shell: false
|
||||
})
|
||||
|
||||
child.on('close', () => resolve(true))
|
||||
child.on('error', () => resolve(true))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user