feat: implement Nginx and Apache configuration management and service control IPC handlers
This commit is contained in:
@@ -232,9 +232,13 @@ async function rebuildApacheConfig(forceProjects: boolean = false): Promise<{ bi
|
||||
async function restartApache(): Promise<{ success: boolean; message: string }> {
|
||||
try {
|
||||
const { binPath, configPath } = await rebuildApacheConfig(false)
|
||||
const settings = configService.getSettings()
|
||||
|
||||
await processManager.forceKillAll('apache')
|
||||
await processManager.stopService('apache')
|
||||
// Force kill port to be absolutely sure
|
||||
await processManager.killByPort('apache', settings.apachePort || '8080')
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
|
||||
const success = await processManager.startService('apache', binPath, ['-f', configPath], false)
|
||||
@@ -275,6 +279,9 @@ export function registerIpcHandlers(): void {
|
||||
|
||||
if (serviceName === 'apache') {
|
||||
const { binPath, configPath } = await rebuildApacheConfig(false)
|
||||
const settings = configService.getSettings()
|
||||
// Ensure port is free
|
||||
await processManager.killByPort('apache', settings.apachePort || '8080')
|
||||
const success = await processManager.startService('apache', binPath, ['-f', configPath], false)
|
||||
if (!success) {
|
||||
const errorLogs = await processManager.getLastErrorLogs('apache')
|
||||
|
||||
@@ -517,7 +517,15 @@ function App(): JSX.Element {
|
||||
if (window.api && window.api.invoke) {
|
||||
const result = await window.api.invoke('nginx:config:save', nginxConfig)
|
||||
if (result.success) {
|
||||
setNotification({ open: true, message: t('server.nginx.config_saved'), severity: 'success' })
|
||||
Swal.fire({
|
||||
title: t('common.success'),
|
||||
text: t('server.nginx.config_saved'),
|
||||
icon: 'success',
|
||||
background: '#1e1e1e',
|
||||
color: '#fff',
|
||||
confirmButtonColor: '#153E5E',
|
||||
customClass: { popup: 'swal2-dark-popup' }
|
||||
})
|
||||
setIsNginxConfigOpen(false)
|
||||
}
|
||||
}
|
||||
@@ -535,7 +543,15 @@ function App(): JSX.Element {
|
||||
if (window.api && window.api.invoke) {
|
||||
const result = await window.api.invoke('apache:config:save', apacheConfig)
|
||||
if (result.success) {
|
||||
setNotification({ open: true, message: t('server.apache.config_saved'), severity: 'success' })
|
||||
Swal.fire({
|
||||
title: t('common.success'),
|
||||
text: t('server.apache.config_saved'),
|
||||
icon: 'success',
|
||||
background: '#1e1e1e',
|
||||
color: '#fff',
|
||||
confirmButtonColor: '#153E5E',
|
||||
customClass: { popup: 'swal2-dark-popup' }
|
||||
})
|
||||
setIsApacheConfigOpen(false)
|
||||
}
|
||||
}
|
||||
@@ -616,7 +632,15 @@ function App(): JSX.Element {
|
||||
if (window.api && window.api.invoke) {
|
||||
const result = await window.api.invoke('project:nginx:save', selectedProjectHost, projectNginxConfig)
|
||||
if (result.success) {
|
||||
setNotification({ open: true, message: t('server.nginx.config_saved'), severity: 'success' })
|
||||
Swal.fire({
|
||||
title: t('common.success'),
|
||||
text: t('server.nginx.config_saved'),
|
||||
icon: 'success',
|
||||
background: '#1e1e1e',
|
||||
color: '#fff',
|
||||
confirmButtonColor: '#153E5E',
|
||||
customClass: { popup: 'swal2-dark-popup' }
|
||||
})
|
||||
setIsProjectNginxConfigOpen(false)
|
||||
}
|
||||
}
|
||||
@@ -1099,7 +1123,15 @@ function App(): JSX.Element {
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
window.api.invoke('services:reload', 'nginx').then((res: any) => {
|
||||
setNotification({ open: true, message: res.message, severity: res.success ? 'success' : 'error' })
|
||||
Swal.fire({
|
||||
title: res.success ? t('common.success') : t('common.error'),
|
||||
text: res.message,
|
||||
icon: res.success ? 'success' : 'error',
|
||||
background: '#1e1e1e',
|
||||
color: '#fff',
|
||||
confirmButtonColor: '#153E5E',
|
||||
customClass: { popup: 'swal2-dark-popup' }
|
||||
})
|
||||
})
|
||||
}}
|
||||
title={t('server.nginx.save_reload')}
|
||||
@@ -1150,6 +1182,27 @@ function App(): JSX.Element {
|
||||
>
|
||||
<SettingsIcon fontSize="small" />
|
||||
</IconButton>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
window.api.invoke('services:reload', 'apache').then((res: any) => {
|
||||
Swal.fire({
|
||||
title: res.success ? t('common.success') : t('common.error'),
|
||||
text: res.message,
|
||||
icon: res.success ? 'success' : 'error',
|
||||
background: '#1e1e1e',
|
||||
color: '#fff',
|
||||
confirmButtonColor: '#153E5E',
|
||||
customClass: { popup: 'swal2-dark-popup' }
|
||||
})
|
||||
})
|
||||
}}
|
||||
title={t('server.apache.save_reload')}
|
||||
size="small"
|
||||
disabled={status.apache !== 'running'}
|
||||
sx={{ bgcolor: 'rgba(255,255,255,0.05)', '&:hover': { color: 'primary.main' } }}
|
||||
>
|
||||
<RefreshIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</Box>
|
||||
<Switch
|
||||
checked={status.apache === 'running' || status.apache === 'starting'}
|
||||
|
||||
Reference in New Issue
Block a user