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