mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-06 05:24:33 +08:00
fix: Fix scheduled task execution exceptions (#8030)
This commit is contained in:
parent
9a597adff3
commit
6b0445763b
7 changed files with 27 additions and 17 deletions
|
@ -273,6 +273,7 @@ func (u *CronjobService) Delete(req dto.CronjobBatchDelete) error {
|
|||
if cronjob.ID == 0 {
|
||||
return errors.New("find cronjob in db failed")
|
||||
}
|
||||
_ = os.RemoveAll(path.Join(global.Dir.DataDir, "task/shell", cronjob.Name))
|
||||
ids := strings.Split(cronjob.EntryIDs, ",")
|
||||
for _, id := range ids {
|
||||
idItem, _ := strconv.Atoi(id)
|
||||
|
|
|
@ -97,8 +97,7 @@ func (u *CronjobService) handleShell(cronjob model.Cronjob, taskID string) error
|
|||
if len(cronjob.Command) != 0 {
|
||||
command = cronjob.Command
|
||||
}
|
||||
scriptFile, _ := os.ReadFile(cronjob.Script)
|
||||
return cmd.ExecShellWithTask(taskItem, 24*time.Hour, "docker", "exec", cronjob.ContainerName, command, "-c", strings.ReplaceAll(string(scriptFile), "\"", "\\\""))
|
||||
return cmd.ExecShellWithTask(taskItem, 24*time.Hour, "docker", "exec", cronjob.ContainerName, command, "-c", strings.ReplaceAll(cronjob.Script, "\"", "\\\""))
|
||||
}
|
||||
if len(cronjob.Executor) == 0 {
|
||||
cronjob.Executor = "bash"
|
||||
|
|
|
@ -51,16 +51,17 @@ var WebUrlMap = map[string]struct{}{
|
|||
"/ai/model": {},
|
||||
"/ai/gpu": {},
|
||||
|
||||
"/containers": {},
|
||||
"/containers/container": {},
|
||||
"/containers/image": {},
|
||||
"/containers/network": {},
|
||||
"/containers/volume": {},
|
||||
"/containers/repo": {},
|
||||
"/containers/compose": {},
|
||||
"/containers/template": {},
|
||||
"/containers/setting": {},
|
||||
"/containers/dashboard": {},
|
||||
"/containers": {},
|
||||
"/containers/container": {},
|
||||
"containers/container/operate": {},
|
||||
"/containers/image": {},
|
||||
"/containers/network": {},
|
||||
"/containers/volume": {},
|
||||
"/containers/repo": {},
|
||||
"/containers/compose": {},
|
||||
"/containers/template": {},
|
||||
"/containers/setting": {},
|
||||
"/containers/dashboard": {},
|
||||
|
||||
"/cronjobs": {},
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
:page-sizes="[5, 10, 20, 50, 100]"
|
||||
@size-change="sizeChange"
|
||||
@current-change="currentChange"
|
||||
:small="mobile"
|
||||
:small="mobile || paginationConfig.small"
|
||||
:layout="mobile ? 'total, prev, pager, next' : 'total, sizes, prev, pager, next, jumper'"
|
||||
/>
|
||||
</slot>
|
||||
|
|
|
@ -62,6 +62,7 @@ const paginationConfig = reactive({
|
|||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
small: true,
|
||||
});
|
||||
const taskLogRef = ref();
|
||||
const req = reactive({
|
||||
|
|
|
@ -29,7 +29,12 @@
|
|||
<el-button link icon="CircleCheck" type="success" />
|
||||
{{ $t('terminal.local') }}
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item v-for="item in nodes" :key="item.name" :command="item.name">
|
||||
<el-dropdown-item
|
||||
:disabled="item.status !== 'Healthy'"
|
||||
v-for="item in nodes"
|
||||
:key="item.name"
|
||||
:command="item.name"
|
||||
>
|
||||
<el-button v-if="item.status === 'Healthy'" link icon="CircleCheck" type="success" />
|
||||
<el-button v-else link icon="Warning" type="danger" />
|
||||
{{ item.name }}
|
||||
|
|
|
@ -271,7 +271,10 @@
|
|||
</el-card>
|
||||
|
||||
<el-form-item :label="$t('cronjob.shellContent')" prop="script" class="mt-5">
|
||||
<el-radio-group v-model="dialogData.rowData!.scriptMode">
|
||||
<el-radio-group
|
||||
@change="dialogData.rowData!.script = ''"
|
||||
v-model="dialogData.rowData!.scriptMode"
|
||||
>
|
||||
<el-radio value="input">{{ $t('commons.button.edit') }}</el-radio>
|
||||
<el-radio value="select">{{ $t('container.pathSelect') }}</el-radio>
|
||||
</el-radio-group>
|
||||
|
@ -280,8 +283,7 @@
|
|||
v-model="dialogData.rowData!.script"
|
||||
placeholder="#Define or paste the content of your shell file here"
|
||||
mode="javascript"
|
||||
:heightDiff="0"
|
||||
:min-height="200"
|
||||
:heightDiff="400"
|
||||
/>
|
||||
<el-input
|
||||
v-if="dialogData.rowData!.scriptMode=== 'select'"
|
||||
|
@ -792,6 +794,7 @@ const rules = reactive({
|
|||
],
|
||||
|
||||
script: [{ validator: verifyScript, trigger: 'blur', required: true }],
|
||||
containerName: [Rules.requiredSelect],
|
||||
appID: [Rules.requiredSelect],
|
||||
website: [Rules.requiredSelect],
|
||||
dbName: [Rules.requiredSelect],
|
||||
|
|
Loading…
Add table
Reference in a new issue