diff --git a/.gitignore b/.gitignore index 0026861..e33b4f3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.o *.a *.so +*.idea # Folders _obj diff --git a/cron.go b/cron.go index c7e9176..7795f2a 100644 --- a/cron.go +++ b/cron.go @@ -2,6 +2,7 @@ package cron import ( "context" + "runtime" "sort" "sync" "time" @@ -97,17 +98,17 @@ func (s byTime) Less(i, j int) bool { // // Available Settings // -// Time Zone -// Description: The time zone in which schedules are interpreted -// Default: time.Local +// Time Zone +// Description: The time zone in which schedules are interpreted +// Default: time.Local // -// Parser -// Description: Parser converts cron spec strings into cron.Schedules. -// Default: Accepts this spec: https://en.wikipedia.org/wiki/Cron +// Parser +// Description: Parser converts cron spec strings into cron.Schedules. +// Default: Accepts this spec: https://en.wikipedia.org/wiki/Cron // -// Chain -// Description: Wrap submitted jobs to customize behavior. -// Default: A chain that recovers panics and logs them to stderr. +// Chain +// Description: Wrap submitted jobs to customize behavior. +// Default: A chain that recovers panics and logs them to stderr. // // See "cron.With*" to modify the default behavior. func New(opts ...Option) *Cron { @@ -308,7 +309,13 @@ func (c *Cron) run() { func (c *Cron) startJob(j Job) { c.jobWaiter.Add(1) go func() { - defer c.jobWaiter.Done() + defer func() { + if rec := recover(); rec != nil { + buf := make([]byte, 1<<16) + runtime.Stack(buf, true) + } + c.jobWaiter.Done() + }() j.Run() }() }