mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-01-04 05:56:04 +08:00
fix: Add autostart configuration for supervisor (#9831)
This commit is contained in:
parent
0f138c1b7c
commit
d48166f546
14 changed files with 44 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ type SupervisorProcessConfig struct {
|
|||
Dir string `json:"dir"`
|
||||
Numprocs string `json:"numprocs"`
|
||||
AutoRestart string `json:"autoRestart"`
|
||||
AutoStart string `json:"autoStart"`
|
||||
}
|
||||
|
||||
type SupervisorProcessFileReq struct {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ type SupervisorProcessConfig struct {
|
|||
Msg string `json:"msg"`
|
||||
Status []ProcessStatus `json:"status"`
|
||||
AutoRestart string `json:"autoRestart"`
|
||||
AutoStart string `json:"autoStart"`
|
||||
}
|
||||
|
||||
type ProcessStatus struct {
|
||||
|
|
|
|||
|
|
@ -323,6 +323,7 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c
|
|||
_, _ = section.NewKey("command", strings.TrimSpace(req.Command))
|
||||
_, _ = section.NewKey("directory", req.Dir)
|
||||
_, _ = section.NewKey("autorestart", req.AutoRestart)
|
||||
_, _ = section.NewKey("autostart", req.AutoStart)
|
||||
_, _ = section.NewKey("startsecs", "3")
|
||||
_, _ = section.NewKey("stdout_logfile", outLog)
|
||||
_, _ = section.NewKey("stderr_logfile", errLog)
|
||||
|
|
@ -360,6 +361,8 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c
|
|||
numprocsKey.SetValue(req.Numprocs)
|
||||
autoRestart := section.Key("autorestart")
|
||||
autoRestart.SetValue(req.AutoRestart)
|
||||
autoStart := section.Key("autostart")
|
||||
autoStart.SetValue(req.AutoStart)
|
||||
|
||||
if err = configFile.SaveTo(iniPath); err != nil {
|
||||
return err
|
||||
|
|
@ -429,6 +432,9 @@ func handleProcessConfig(configDir, containerName string) ([]response.Supervisor
|
|||
if autoRestart, _ := section.GetKey("autorestart"); autoRestart != nil {
|
||||
config.AutoRestart = autoRestart.Value()
|
||||
}
|
||||
if autoStart, _ := section.GetKey("autostart"); autoStart != nil {
|
||||
config.AutoStart = autoStart.Value()
|
||||
}
|
||||
_ = getProcessStatus(&config, containerName)
|
||||
result = append(result, config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ export namespace HostTool {
|
|||
numprocs: string;
|
||||
status?: ProcessStatus[];
|
||||
autoRestart: string;
|
||||
autoStart: string;
|
||||
}
|
||||
|
||||
export interface ProcessStatus {
|
||||
|
|
|
|||
|
|
@ -2864,6 +2864,9 @@ const message = {
|
|||
manage: 'Management',
|
||||
autoRestart: 'Auto Restart',
|
||||
EXITED: 'Exited',
|
||||
autoRestartHelper: 'Whether to automatically restart the program after it crashes',
|
||||
autoStart: 'Auto Start',
|
||||
autoStartHelper: 'Whether to automatically start the service after Supervisor starts',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2758,6 +2758,9 @@ const message = {
|
|||
manage: '管理',
|
||||
autoRestart: '自動再起動',
|
||||
EXITED: '終了しました',
|
||||
autoRestartHelper: 'プログラムが異常終了した後に自動的に再起動するかどうか',
|
||||
autoStart: '自動起動',
|
||||
autoStartHelper: 'Supervisor 起動後にサービスを自動的に起動するかどうか',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2709,6 +2709,9 @@ const message = {
|
|||
manage: '관리',
|
||||
autoRestart: '자동 재시작',
|
||||
EXITED: '종료됨',
|
||||
autoRestartHelper: '프로그램이 비정상적으로 종료된 후 자동으로 재시작할지 여부',
|
||||
autoStart: '자동 시작',
|
||||
autoStartHelper: 'Supervisor 시작 후 서비스를 자동으로 시작할지 여부',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2820,6 +2820,10 @@ const message = {
|
|||
manage: 'Pengurusan',
|
||||
autoRestart: 'Auto Restart',
|
||||
EXITED: 'Telah keluar',
|
||||
autoRestartHelper:
|
||||
'Sama ada untuk memulakan semula program secara automatik selepas ia tamat secara luar jangka',
|
||||
autoStart: 'Mula Automatik',
|
||||
autoStartHelper: 'Sama ada untuk memulakan perkhidmatan secara automatik selepas Supervisor mula',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2824,6 +2824,9 @@ const message = {
|
|||
manage: 'Gerenciamento',
|
||||
autoRestart: 'Reinicialização Automática',
|
||||
EXITED: 'Saiu',
|
||||
autoRestartHelper: 'Se o programa falhar, reiniciar automaticamente',
|
||||
autoStart: 'Início Automático',
|
||||
autoStartHelper: 'Se o serviço deve ser iniciado automaticamente após o Supervisor iniciar',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2816,6 +2816,9 @@ const message = {
|
|||
manage: 'Управление',
|
||||
autoRestart: 'Автоматический перезапуск',
|
||||
EXITED: 'Вышел',
|
||||
autoRestartHelper: 'Автоматически перезапускать программу после её аварийного завершения',
|
||||
autoStart: 'Автозапуск',
|
||||
autoStartHelper: 'Автоматически запускать сервис после запуска Supervisor',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2902,6 +2902,9 @@ const message = {
|
|||
manage: 'Yönetim',
|
||||
autoRestart: 'Otomatik Yeniden Başlatma',
|
||||
EXITED: 'Çıkıldı',
|
||||
autoRestartHelper: 'Program çöktükten sonra otomatik olarak yeniden başlatılsın mı?',
|
||||
autoStart: 'Otomatik Başlat',
|
||||
autoStartHelper: 'Supervisor başlatıldıktan sonra servis otomatik olarak başlatılsın mı?',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2672,6 +2672,9 @@ const message = {
|
|||
manage: '管理',
|
||||
autoRestart: '自動重啟',
|
||||
EXITED: '已退出',
|
||||
autoRestartHelper: '程式異常退出後是否自動重啟',
|
||||
autoStart: '自動啟動',
|
||||
autoStartHelper: 'Supervisor 啟動後是否自動啟動服務',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -2662,6 +2662,9 @@ const message = {
|
|||
manage: '管理',
|
||||
autoRestart: '自动重启',
|
||||
EXITED: '已退出',
|
||||
autoRestartHelper: '程序异常退出后是否自动重启',
|
||||
autoStart: '自动启动',
|
||||
autoStartHelper: 'Supervisor 启动后是否自动启动服务',
|
||||
},
|
||||
},
|
||||
xpack: {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@
|
|||
</el-form-item>
|
||||
<el-form-item :label="$t('tool.supervisor.autoRestart')" prop="autoRestart">
|
||||
<el-switch v-model="process.autoRestart" active-value="true" inactive-value="false"></el-switch>
|
||||
<span class="input-help">{{ $t('tool.supervisor.autoRestartHelper') }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('tool.supervisor.autoStart')" prop="autoStart">
|
||||
<el-switch v-model="process.autoStart" active-value="true" inactive-value="false"></el-switch>
|
||||
<span class="input-help">{{ $t('tool.supervisor.autoStartHelper') }}</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
|
|
@ -74,6 +79,7 @@ const initData = () => ({
|
|||
numprocsNum: 1,
|
||||
numprocs: '1',
|
||||
autoRestart: 'true',
|
||||
autoStart: 'true',
|
||||
});
|
||||
const process = ref(initData());
|
||||
|
||||
|
|
@ -105,6 +111,7 @@ const acceptParams = (operate: string, config: HostTool.SupersivorProcess) => {
|
|||
numprocsNum: 1,
|
||||
numprocs: config.numprocs,
|
||||
autoRestart: config.autoRestart,
|
||||
autoStart: config.autoStart,
|
||||
};
|
||||
process.value.numprocsNum = Number(config.numprocs);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue