I have a task which I'd like to be the last task performed by the Server, with the server closing following completion. I've tried implementing this sending TSTP/TERM to the current PID running the handler, but the server still processes other tasks.
By way of a simple example, HandleShutdownTask should run, followed by shutdown of the Async server / worker (and then the host shortly after)
func HandleShutdownTask(ctx context.Context, t *asynq.Task) error {
log.Info("[shutdown] Shutdown Queued")
err = exec.Command("shutdown").Run()
if err != nil {
log.Error("Failed to run shutdown command")
os.Exit(1)
}
syscall.Kill(syscall.Getpid(), syscall.SIGTSTP)
syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
return nil
However, the syscall signal implementation above doesn't work, with other tasks starting to be processed following completion of the above.
Describe the solution you'd like
A means to instruct the Async Server to terminate from within a handler, following completion of the current task.
Or someone to tell me I'm approaching this wrong :D
I have a task which I'd like to be the last task performed by the Server, with the server closing following completion. I've tried implementing this sending TSTP/TERM to the current PID running the handler, but the server still processes other tasks.
By way of a simple example,
HandleShutdownTask
should run, followed by shutdown of the Async server / worker (and then the host shortly after)However, the syscall signal implementation above doesn't work, with other tasks starting to be processed following completion of the above.
Describe the solution you'd like A means to instruct the Async Server to terminate from within a handler, following completion of the current task.