mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 21:38:57 +08:00
feat: support config environment for supervisor (#10471)
This commit is contained in:
parent
0433a26a07
commit
672fedc7e5
7 changed files with 22 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ type SupervisorProcessConfig struct {
|
|||
Numprocs string `json:"numprocs"`
|
||||
AutoRestart string `json:"autoRestart"`
|
||||
AutoStart string `json:"autoStart"`
|
||||
Environment string `json:"environment"`
|
||||
}
|
||||
|
||||
type SupervisorProcessFileReq struct {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ type SupervisorProcessConfig struct {
|
|||
Status []ProcessStatus `json:"status"`
|
||||
AutoRestart string `json:"autoRestart"`
|
||||
AutoStart string `json:"autoStart"`
|
||||
Environment string `json:"environment"`
|
||||
}
|
||||
|
||||
type ProcessStatus struct {
|
||||
|
|
|
|||
|
|
@ -333,6 +333,9 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c
|
|||
_, _ = section.NewKey("priority", "999")
|
||||
_, _ = section.NewKey("numprocs", req.Numprocs)
|
||||
_, _ = section.NewKey("process_name", "%(program_name)s_%(process_num)02d")
|
||||
if req.Environment != "" {
|
||||
_, _ = section.NewKey("environment", req.Environment)
|
||||
}
|
||||
|
||||
if err = configFile.SaveTo(iniPath); err != nil {
|
||||
return err
|
||||
|
|
@ -363,6 +366,8 @@ func handleProcess(supervisordDir string, req request.SupervisorProcessConfig, c
|
|||
autoRestart.SetValue(req.AutoRestart)
|
||||
autoStart := section.Key("autostart")
|
||||
autoStart.SetValue(req.AutoStart)
|
||||
environment := section.Key("environment")
|
||||
environment.SetValue(req.Environment)
|
||||
|
||||
if err = configFile.SaveTo(iniPath); err != nil {
|
||||
return err
|
||||
|
|
@ -435,6 +440,9 @@ func handleProcessConfig(configDir, containerName string) ([]response.Supervisor
|
|||
if autoStart, _ := section.GetKey("autostart"); autoStart != nil {
|
||||
config.AutoStart = autoStart.Value()
|
||||
}
|
||||
if environment, _ := section.GetKey("environment"); environment != nil {
|
||||
config.Environment = environment.Value()
|
||||
}
|
||||
_ = getProcessStatus(&config, containerName)
|
||||
result = append(result, config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ export namespace HostTool {
|
|||
status?: ProcessStatus[];
|
||||
autoRestart: string;
|
||||
autoStart: string;
|
||||
environment: string;
|
||||
}
|
||||
|
||||
export interface ProcessStatus {
|
||||
|
|
|
|||
|
|
@ -213,6 +213,7 @@ export namespace Runtime {
|
|||
dir: string;
|
||||
numprocs: string;
|
||||
id: number;
|
||||
environment: string;
|
||||
}
|
||||
|
||||
export interface PHPContainerConfig {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@
|
|||
<el-form-item :label="$t('tool.supervisor.numprocs')" prop="numprocsNum">
|
||||
<el-input type="number" v-model.number="process.numprocsNum"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('process.env')" prop="environment">
|
||||
<el-input type="text" v-model="process.environment"></el-input>
|
||||
</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>
|
||||
|
|
@ -84,6 +87,7 @@ const initData = () => ({
|
|||
numprocs: '1',
|
||||
autoRestart: 'true',
|
||||
autoStart: 'true',
|
||||
environment: '',
|
||||
});
|
||||
const process = ref(initData());
|
||||
|
||||
|
|
@ -116,6 +120,7 @@ const acceptParams = (operate: string, config: HostTool.SupersivorProcess) => {
|
|||
numprocs: config.numprocs,
|
||||
autoRestart: config.autoRestart,
|
||||
autoStart: config.autoStart,
|
||||
environment: config.environment || '',
|
||||
};
|
||||
process.value.numprocsNum = Number(config.numprocs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@
|
|||
<el-form-item :label="$t('tool.supervisor.numprocs')" prop="numprocsNum">
|
||||
<el-input type="number" v-model.number="process.numprocsNum"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('process.env')" prop="environment">
|
||||
<el-input type="text" v-model="process.environment"></el-input>
|
||||
</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>
|
||||
</el-form-item>
|
||||
|
|
@ -77,6 +80,7 @@ const initData = (runtimeID: number) => ({
|
|||
id: runtimeID,
|
||||
autoRestart: 'true',
|
||||
autoStart: 'true',
|
||||
environment: '',
|
||||
});
|
||||
const process = ref(initData(0));
|
||||
const em = defineEmits(['close']);
|
||||
|
|
@ -105,6 +109,7 @@ const acceptParams = (operate: string, config: HostTool.SupersivorProcess, id: n
|
|||
id: id,
|
||||
autoRestart: config.autoRestart,
|
||||
autoStart: config.autoStart,
|
||||
environment: config.environment || '',
|
||||
};
|
||||
process.value.numprocsNum = Number(config.numprocs);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue