INNER CODE UNIT · JavaScript

decorateWithSignalHandler

godaddy/terminus · lib/terminus.js:130

function decorateWithSignalHandler (server, state, options) {
  const { signals, useExit0, onSignal, beforeShutdown, onShutdown, timeout, logger } = options

  stoppable(server, timeout)

  const asyncServerStop = promisify(server.stop).bind(server)

  async function cleanup (signal) {
    if (!state.isShuttingDown) {
      state.isShuttingDown = true
      try {
        await beforeShutdown()
        await asyncServerStop()
        await onSignal()
        await onShutdown()
        if (useExit0) {
          // Exit process
          process.exit(0)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…