Graceful shutdown

enhancement

#1

original discussion

Flow

  • Received <-xsignal.WaitForInterrupt().

  • Close listener with listener.Close() to stop Accepting new application/service connections.

  • Disable ExecuteTask() API by immediately returning every request with “shutting down” error. This way, already connected services cannot receive new execution requests with ListenTask(). (This error can be applied to incoming ListenResult(), ListenEvent() & ListenTask() requests for convenience.)

  • Call stopRunningServices() to send shutdown signals to running services. So, connected services will gracefully shutdown by finishing ongoing tasks and sending SubmitResult()s to Core.

  • Drain pubsub queue by sending results for open ListenResult() streams. So, applications will receive their last results. Relevant lines.

  • Call service.Close() afterwards to close all connections for all clients.