mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-10-12 00:16:37 +08:00
fix: Fix import issues of shell cronjob (#9726)
This commit is contained in:
parent
bc376ec495
commit
ed3e738fff
1 changed files with 5 additions and 4 deletions
|
@ -276,15 +276,16 @@ func (u *CronjobService) Import(req []dto.CronjobTrans) error {
|
||||||
cronjob.DBName = strings.Join(dbIDs, ",")
|
cronjob.DBName = strings.Join(dbIDs, ",")
|
||||||
case "shell":
|
case "shell":
|
||||||
if len(item.ContainerName) != 0 {
|
if len(item.ContainerName) != 0 {
|
||||||
|
cronjob.Script = item.Script
|
||||||
client, err := docker.NewDockerClient()
|
client, err := docker.NewDockerClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
hasNotFound = true
|
hasNotFound = true
|
||||||
continue
|
break
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
if _, err := client.ContainerStats(context.Background(), item.ContainerName, false); err != nil {
|
if _, err := client.ContainerStats(context.Background(), item.ContainerName, false); err != nil {
|
||||||
hasNotFound = true
|
hasNotFound = true
|
||||||
continue
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch item.ScriptMode {
|
switch item.ScriptMode {
|
||||||
|
@ -292,13 +293,13 @@ func (u *CronjobService) Import(req []dto.CronjobTrans) error {
|
||||||
library, _ := scriptRepo.Get(repo.WithByName(item.ScriptName))
|
library, _ := scriptRepo.Get(repo.WithByName(item.ScriptName))
|
||||||
if library.ID == 0 {
|
if library.ID == 0 {
|
||||||
hasNotFound = true
|
hasNotFound = true
|
||||||
continue
|
break
|
||||||
}
|
}
|
||||||
cronjob.ScriptID = library.ID
|
cronjob.ScriptID = library.ID
|
||||||
case "select":
|
case "select":
|
||||||
if _, err := os.Stat(item.Script); err != nil {
|
if _, err := os.Stat(item.Script); err != nil {
|
||||||
hasNotFound = true
|
hasNotFound = true
|
||||||
continue
|
break
|
||||||
}
|
}
|
||||||
cronjob.Script = item.Script
|
cronjob.Script = item.Script
|
||||||
case "input":
|
case "input":
|
||||||
|
|
Loading…
Add table
Reference in a new issue