feat: initialize Multi-PHP server project with Electron, React, and service management infrastructure

This commit is contained in:
Ümit Tunç
2026-03-28 08:42:23 +03:00
parent 19ace0e11b
commit 5372448ead
27 changed files with 10627 additions and 0 deletions
+72
View File
@@ -0,0 +1,72 @@
import { ipcMain, app } from 'electron'
import { processManager } from '../services/ProcessManager'
import { configService } from '../services/ConfigService'
import { downloadService } from '../services/DownloadService'
import path from 'path'
export function registerIpcHandlers(): void {
// Service management
ipcMain.handle('services:start', async (_event, serviceName: string) => {
try {
if (serviceName === 'nginx') {
const rootPath = path.join(app.getAppPath(), 'www')
const configPath = await configService.generateConfig('nginx.conf.template', 'nginx.conf', {
PORT: '80',
ROOT: rootPath
})
const binPath = downloadService.getBinPath('nginx', 'nginx.exe')
const success = await processManager.startService('nginx', binPath, ['-c', configPath])
return { success, message: success ? 'Nginx başlatıldı.' : 'Nginx başlatılamadı.' }
}
if (serviceName === 'php') {
const configPath = await configService.generateConfig('php.ini.template', 'php.ini', {})
const binPath = downloadService.getBinPath('php8.2', 'php-cgi.exe')
const success = await processManager.startService('php', binPath, ['-b', '127.0.0.1:9001', '-c', configPath])
return { success, message: success ? 'PHP başlatıldı.' : 'PHP başlatılamadı.' }
}
if (serviceName === 'mysql') {
const dataDir = path.join(app.getPath('userData'), 'mysql_data')
const configPath = await configService.generateConfig('my.ini.template', 'my.ini', {
DATADIR: dataDir,
SOCKET: '/tmp/mysql.sock'
})
const binPath = downloadService.getBinPath('mysql', 'bin/mysqld.exe')
const success = await processManager.startService('mysql', binPath, ['--defaults-file=' + configPath])
return { success, message: success ? 'MySQL başlatıldı.' : 'MySQL başlatılamadı.' }
}
return { success: false, message: 'Bilinmeyen servis.' }
} catch (error: any) {
console.error('Service start error:', error)
return { success: false, message: `Hata: ${error.message}` }
}
})
ipcMain.handle('services:stop', async (_event, serviceName: string) => {
const success = await processManager.stopService(serviceName)
return { success, message: success ? `${serviceName} durduruldu.` : `${serviceName} zaten durmuş.` }
})
ipcMain.handle('services:status', async () => {
return processManager.getStatuses()
})
// Binary management
ipcMain.handle('binaries:download', async (_event, { name, url }) => {
return downloadService.downloadAndExtract(url, name, (p) => {
// TODO: Emit progress to renderer via webContents.send
console.log(`Download progress for ${name}: ${p}%`)
})
})
// Config management
ipcMain.handle('config:get', async (_event, key: string) => {
return null
})
ipcMain.handle('config:save', async (_event, config: any) => {
return { success: true }
})
}