Skip to main content
version 1.0.0

Graceful Shutdown


Graceful shutdown means that the OS (operating system) can safely shut down its processes and close all connections, however long that takes. This helps to prevent accidental data loss or other unexpected problems if the shutdown is performed intentionally by the user.


Athenna already comes with graceful shutdown configured by default using the gracefulShutdown object in config/app.js file. In this object you can configure all SIGNALS that Node.js process will listen for in your application. Athenna comes with SIGINT and SIGTERM already configured by default:

import { ProviderHelper } from '@athenna/core'

gracefulShutdown: {
SIGINT: async () => {
await ProviderHelper.shutdownAll(false)

SIGTERM: async signal => {
await ProviderHelper.shutdownAll()

process.kill(, signal)

It's imperative that you always call the ProviderHelper.shutdownAll() method in your signals configurations. This method is who will call the shutdown method of Athenna providers.

Disabling graceful shutdown

To disable the graceful shutdown of some SIGNAL you can just remove it from gracefulShutdown object in config/app.js:

gracefulShutdown: {}