设置了cron,结果cron的结果是一直pending
先cancel再执行,就可以正确运行。
好像是因为没有给分配节点
Random node 可能不大行
但是选了all,指定好执行的node,也一直在pending
Cancel后再restart就可以执行成功。
而且日志是空的:
设置了59分钟执行一次的cron,结果出来了一堆任务,明显间隔远小于59分钟
docker中的日志:
[GIN] 2021/12/14 - 17:19:44 | 200 | 1.687052ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64/logs?page=1&size=1000"
[GIN] 2021/12/14 - 17:19:44 | 200 | 1.805117ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64/logs?page=1&size=1000"
[GIN] 2021/12/14 - 17:19:44 | 200 | 1.66901ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64/logs?page=1&size=1000"
[GIN] 2021/12/14 - 17:19:49 | 200 | 1.989707ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64"
[GIN] 2021/12/14 - 17:19:49 | 200 | 1.752247ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64/logs?page=1&size=1000"
[GIN] 2021/12/14 - 17:19:49 | 200 | 1.72434ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64"
[GIN] 2021/12/14 - 17:19:49 | 200 | 2.052601ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64"
[GIN] 2021/12/14 - 17:19:49 | 200 | 1.725489ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64/logs?page=1&size=1000"
[GIN] 2021/12/14 - 17:19:49 | 200 | 1.795195ms | 127.0.0.1 | GET "/tasks/61b8511cb3dff6964e219f64/logs?page=1&size=1000"
[GIN] 2021/12/14 - 17:19:53 | 200 | 9.621834ms | 127.0.0.1 | GET "/nodes?all=true"
[GIN] 2021/12/14 - 17:19:53 | 200 | 3.065192ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:19:53 | 200 | 9.633242ms | 127.0.0.1 | GET "/spiders?all=true"
[GIN] 2021/12/14 - 17:19:58 | 200 | 3.447695ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:03 | 200 | 3.371247ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:08 | 200 | 3.678794ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:13 | 200 | 3.382504ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:18 | 200 | 3.058961ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:23 | 200 | 3.091996ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:28 | 200 | 3.094828ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:33 | 200 | 3.11339ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:38 | 200 | 3.062865ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:43 | 200 | 3.064497ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:48 | 200 | 3.093133ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:53 | 200 | 3.360337ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:20:58 | 200 | 3.534331ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
2021/12/14 17:21:00 info cron: wake now 2021-12-14 17:21:00.000896405 +0800 CST
2021/12/14 17:21:00 info cron: run now 2021-12-14 17:21:00.000896405 +0800 CST entry 1 next 2021-12-14 17:24:00 +0800 CST
2021/12/14 17:21:00 error cron: panic stack ...
goroutine 204019 [running]:
github.com/robfig/cron/v3.Recover.func1.1.1(0x141aa90, 0x1b06f30)
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/chain.go:45 +0xbd
panic(0x1081fc0, 0x1ab6cd0)
/usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/crawlab-team/crawlab-core/models/models.(*User).GetId(0x0, 0x0, 0xc000000000)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/models/user.go:17 +0x17
github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).upsertArtifact(0xc0055b5bc0, 0x1199ec0, 0xc005369560)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:300 +0x438
github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).add(0xc0055b5bc0, 0x5, 0x0)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:182 +0x10a
github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).do(0xc0055b5bc0, 0x11f63da, 0x3, 0x1431208, 0xc0055b5bc0)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:148 +0x94
github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).Add(0xc0055b5bc0, 0xc005369560, 0xc004d4fd70)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:106 +0x45
github.com/crawlab-team/crawlab-core/task/scheduler.(*Service).Enqueue(0xc0001b29c0, 0x143a938, 0xc005369560, 0x1, 0x1)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/task/scheduler/service.go:61 +0x169
github.com/crawlab-team/crawlab-core/spider/admin.(*Service).scheduleTasks(0xc00009fe40, 0xc00537ec58, 0xc0000e77a0, 0xc00537ec58, 0x0)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/spider/admin/service.go:111 +0x3e2
github.com/crawlab-team/crawlab-core/spider/admin.(*Service).Schedule(0xc00009fe40, 0x96f6dfb38ceeb761, 0x600646eec9e214e, 0xc0000e77a0, 0x0, 0x0)
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/spider/admin/service.go:45 +0x85
github.com/crawlab-team/crawlab-core/schedule.(*Service).schedule.func1()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/schedule/service.go:235 +0x489
github.com/robfig/cron/v3.FuncJob.Run(0xc001ba66c0)
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/cron.go:131 +0x25
github.com/robfig/cron/v3.Recover.func1.1()
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/chain.go:53 +0x68
github.com/robfig/cron/v3.FuncJob.Run(0xc0011987e0)
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/cron.go:131 +0x25
github.com/robfig/cron/v3.(*Cron).startJob.func1(0xc00043afa0, 0x1411fe0, 0xc0011987e0)
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/cron.go:307 +0x65
created by github.com/robfig/cron/v3.(*Cron).startJob
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/cron.go:305 +0x73
runtime error: invalid memory address or nil pointer dereference
/go/pkg/mod/github.com/crawlab-team/go-trace@v0.1.0/trace.go:6 github.com/crawlab-team/go-trace.PrintError()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/schedule/logger.go:22 github.com/crawlab-team/crawlab-core/schedule.(*Logger).Error()
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/chain.go:50 github.com/robfig/cron/v3.Recover.func1.1.1()
/usr/local/go/src/runtime/panic.go:965 runtime.gopanic()
/usr/local/go/src/runtime/panic.go:212 runtime.panicmem()
/usr/local/go/src/runtime/signal_unix.go:734 runtime.sigpanic()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/models/user.go:17 github.com/crawlab-team/crawlab-core/models/models.(*User).GetId()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:300 github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).upsertArtifact()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:182 github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).add()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:148 github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).do()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/models/delegate/model.go:106 github.com/crawlab-team/crawlab-core/models/delegate.(*ModelDelegate).Add()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/task/scheduler/service.go:61 github.com/crawlab-team/crawlab-core/task/scheduler.(*Service).Enqueue()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/spider/admin/service.go:111 github.com/crawlab-team/crawlab-core/spider/admin.(*Service).scheduleTasks()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/spider/admin/service.go:45 github.com/crawlab-team/crawlab-core/spider/admin.(*Service).Schedule()
/go/pkg/mod/github.com/crawlab-team/crawlab-core@v0.6.0-beta.20211122.1338/schedule/service.go:235 github.com/crawlab-team/crawlab-core/schedule.(*Service).schedule.func1()
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/cron.go:131 github.com/robfig/cron/v3.FuncJob.Run()
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/chain.go:53 github.com/robfig/cron/v3.Recover.func1.1()
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/cron.go:131 github.com/robfig/cron/v3.FuncJob.Run()
/go/pkg/mod/github.com/robfig/cron/v3@v3.0.0/cron.go:307 github.com/robfig/cron/v3.(*Cron).startJob.func1()
/usr/local/go/src/runtime/asm_amd64.s:1371 runtime.goexit()
[GIN] 2021/12/14 - 17:21:03 | 200 | 3.185996ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:08 | 200 | 3.107337ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:13 | 200 | 3.191596ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:18 | 200 | 3.08863ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:23 | 200 | 3.146218ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:28 | 200 | 3.17616ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:33 | 200 | 3.229348ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:38 | 200 | 3.334611ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:43 | 200 | 3.238885ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:48 | 200 | 4.099721ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:53 | 200 | 3.074866ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:21:58 | 200 | 3.35473ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:22:03 | 200 | 4.329431ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:22:08 | 200 | 6.963332ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:22:13 | 200 | 3.073611ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:22:18 | 200 | 3.091466ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:22:23 | 200 | 3.091449ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:22:28 | 200 | 5.297851ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
[GIN] 2021/12/14 - 17:22:33 | 200 | 3.253731ms | 127.0.0.1 | GET "/schedules?page=1&size=10&conditions=[]&sort=[]"
查看主节点的工作: