feat: implement process management service and IPC bridge with initial renderer UI structure
This commit is contained in:
+38
-4
@@ -6,6 +6,7 @@ import { downloadService } from '../services/DownloadService'
|
||||
import { projectService } from '../services/ProjectService'
|
||||
import { phpManagerService } from '../services/PhpManagerService'
|
||||
import { mySqlManagerService } from '../services/MySqlManagerService'
|
||||
import { nginxManagerService } from '../services/NginxManagerService'
|
||||
import path from 'path'
|
||||
|
||||
function findExecutable(dir: string, name: string): string | null {
|
||||
@@ -49,14 +50,16 @@ export function registerIpcHandlers(): void {
|
||||
}
|
||||
|
||||
if (serviceName === 'php') {
|
||||
const configPath = await configService.generateConfig('php.ini.template', 'php.ini', {})
|
||||
// Find any installed PHP version
|
||||
const binPath = findExecutable(binDir, 'php-cgi.exe')
|
||||
|
||||
if (!binPath) return { success: false, message: 'PHP executable bulunamadı. Lütfen en az bir sürüm indirin.' }
|
||||
|
||||
const extDir = path.join(path.dirname(binPath), 'ext')
|
||||
const configPath = await configService.generateConfig('php.ini.template', 'php.ini', {
|
||||
EXT_DIR: extDir.replace(/\\/g, '\\\\') // PHP ini needs escaped backslashes or forward slashes
|
||||
})
|
||||
|
||||
const success = await processManager.startService('php', binPath, ['-b', `127.0.0.1:${settings.phpPort}`, '-c', configPath])
|
||||
return { success, message: success ? 'PHP başlatıldı.' : 'PHP dosyaları bulunamadı veya port meşgul.' }
|
||||
return { success, message: success ? 'PHP başlatıldı.' : 'PHP devreye alınamadı (Hata loglarını kontrol edin).' }
|
||||
}
|
||||
|
||||
if (serviceName === 'mysql') {
|
||||
@@ -98,6 +101,10 @@ export function registerIpcHandlers(): void {
|
||||
return processManager.getStatuses()
|
||||
})
|
||||
|
||||
ipcMain.handle('services:logs', async (_event, serviceName: string) => {
|
||||
return processManager.getLogs(serviceName)
|
||||
})
|
||||
|
||||
// Binary management
|
||||
ipcMain.handle('binaries:list-php', async () => {
|
||||
return phpManagerService.getVersions()
|
||||
@@ -153,6 +160,33 @@ export function registerIpcHandlers(): void {
|
||||
}
|
||||
})
|
||||
|
||||
// Nginx Versions
|
||||
ipcMain.handle('nginx:versions', async () => {
|
||||
return await nginxManagerService.getVersions()
|
||||
})
|
||||
|
||||
ipcMain.handle('nginx:download', async (event, id: string) => {
|
||||
const versions = await nginxManagerService.getVersions()
|
||||
const version = versions.find(v => v.id === id)
|
||||
if (!version) return { success: false, message: 'Geçersiz Nginx sürümü.' }
|
||||
|
||||
try {
|
||||
nginxManagerService.updateProgress(id, 0, 'downloading')
|
||||
event.sender.send('nginx:progress', { id, progress: 0 })
|
||||
|
||||
await downloadService.downloadAndExtract(version.url, id, (p) => {
|
||||
nginxManagerService.updateProgress(id, p)
|
||||
event.sender.send('nginx:progress', { id, progress: p })
|
||||
})
|
||||
|
||||
nginxManagerService.updateProgress(id, 100, 'installed')
|
||||
return { success: true, message: 'Nginx indirme tamamlandı.' }
|
||||
} catch (error: any) {
|
||||
nginxManagerService.updateProgress(id, 0, 'available')
|
||||
return { success: false, message: `Nginx hatası: ${error.message}` }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('dialog:select-directory', async () => {
|
||||
const result = await dialog.showOpenDialog({
|
||||
properties: ['openDirectory']
|
||||
|
||||
Reference in New Issue
Block a user