gocraft / work

Process background jobs in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Job specific cleanup handler when pool shutdown due to SigTerm

srininara opened this issue · comments

As part of a Job we are able to configure a function that executes to run the job.

If the scheduler (or pool) gets a SigTerm, is there a way for the scheduler to execute a different function with the job parameters and context so that this function can do a cleanup of the job and set the status of the job as needed? This will ensure that jobs don't leave the system in a inconsistent state.

Not sure if middlewares can do this. From the documentation it looks like middlewares are called before the job automatically and we don't have ways to trigger middleware handler on specific scenarios. Also middlewares are not specific to a job so doing it in middleware could be very complex.

Please suggest how we can handle the same.