From bf99a4fb49651ad34f0f383ce2214b190cda11aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Sun, 29 Mar 2026 00:43:11 +0300 Subject: [PATCH] feat: implement process management service and base application UI structure --- config/nginx_project.conf.template | 5 +++-- logs/nginx.pid | 2 +- src/main/ipc/index.ts | 23 +++++++++++++++++++++++ src/main/services/ProcessManager.ts | 11 ++++++++++- src/renderer/src/App.tsx | 21 ++++++++++++++++++--- 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/config/nginx_project.conf.template b/config/nginx_project.conf.template index 896f87a..9861540 100644 --- a/config/nginx_project.conf.template +++ b/config/nginx_project.conf.template @@ -1,8 +1,9 @@ -location /{{HOST}}/ { +location ^~ /{{HOST}}/ { alias "{{PATH}}/"; index index.php index.html; + autoindex on; - # Try the literal URI, then directory, then fallback to index.php + # Try the literal URI, then directory (checks for index), then fallback to root index.php try_files $uri $uri/ /{{HOST}}/index.php?$query_string; # PHP handling nested INSIDE the alias location to maintain context diff --git a/logs/nginx.pid b/logs/nginx.pid index 4ce918a..5e4f92a 100644 --- a/logs/nginx.pid +++ b/logs/nginx.pid @@ -1 +1 @@ -38592 +43936 diff --git a/src/main/ipc/index.ts b/src/main/ipc/index.ts index 5835969..67044ad 100644 --- a/src/main/ipc/index.ts +++ b/src/main/ipc/index.ts @@ -29,6 +29,29 @@ function findExecutable(dir: string, name: string): string | null { export function registerIpcHandlers(): void { // Service management + ipcMain.handle('services:reload', async (_event, serviceName: string) => { + if (serviceName !== 'nginx') return { success: false, message: 'Yalnızca Nginx için reload desteklenmektedir.' } + + try { + // Re-generate config + const binDir = path.join(configService.getBasePath(), 'bin') + const nginxDir = path.join(binDir, 'nginx') + const nginxVersions = fs.readdirSync(nginxDir).filter(f => fs.statSync(path.join(nginxDir, f)).isDirectory()) + const activeVersion = nginxVersions[0] // Simplify: use first installed + if (!activeVersion) throw new Error('Nginx sürümü bulunamadı.') + + const nginxPrefix = path.join(nginxDir, activeVersion) + const binPath = path.join(nginxPrefix, 'nginx.exe') + const configPath = path.join(configService.getBasePath(), 'generated_configs', 'nginx.conf') + + // For reload, we need the same prefix and config + const success = await processManager.runOnce(binPath, ['-p', nginxPrefix, '-c', configPath, '-s', 'reload'], 'nginx') + return { success, message: success ? 'Nginx yapılandırması yeniden yüklendi.' : 'Nginx reload hatası (Nginx çalışmıyor olabilir).' } + } catch (error: any) { + return { success: false, message: `Reload hatası: ${error.message}` } + } + }) + ipcMain.handle('services:start', async (_event, serviceName: string) => { try { const settings = configService.getSettings() diff --git a/src/main/services/ProcessManager.ts b/src/main/services/ProcessManager.ts index ea382a7..6b63ad3 100644 --- a/src/main/services/ProcessManager.ts +++ b/src/main/services/ProcessManager.ts @@ -110,11 +110,20 @@ export class ProcessManager { try { this.addLog(name, `Starting service with: ${binPath} ${args.join(' ')}`) + const serviceEnv = { ...process.env } + const binDirPath = path.dirname(binPath) + if (serviceEnv.PATH) { + serviceEnv.PATH = `${binDirPath}${path.delimiter}${serviceEnv.PATH}` + } else { + serviceEnv.PATH = binDirPath + } + const child = spawn(binPath, args, { shell: shell, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'], - cwd: path.dirname(binPath) + cwd: binDirPath, + env: serviceEnv }) console.log(`[PROCESS] Started ${name} with PID ${child.pid}`) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 5d0c74e..c3f0c28 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -765,9 +765,24 @@ function App(): JSX.Element { Nginx Port: {settings.nginxPort} - handleOpenLogs('nginx')} size="small" sx={{ bgcolor: 'rgba(255,255,255,0.05)' }}> - - + + handleOpenLogs('nginx')} title="Hata Logları" size="small" sx={{ bgcolor: 'rgba(255,255,255,0.05)' }}> + + + { + window.api.invoke('services:reload', 'nginx').then((res: any) => { + setNotification({ open: true, message: res.message, severity: res.success ? 'success' : 'error' }) + }) + }} + title="Yapılandırmayı Yeniden Yükle" + size="small" + disabled={status.nginx !== 'running'} + sx={{ bgcolor: 'rgba(255,255,255,0.05)', '&:hover': { color: 'primary.main' } }} + > + + + handleToggleService('nginx')}