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