Giter Site home page Giter Site logo

node-death's People

Contributors

jprichardson avatar rohanorton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-death's Issues

Can't turn off uncaughtException

There's a bug in this code that prevents you from setting the option uncaughtException to false.

 defaultConfig.uncaughtException = arg.ue || arg.uncaught || arg.exception || true

This will always set the value to true, because the || (or) applies to both undefined as well as false.

A more explicit check is needed

if( arg.ue != null ){
    defaultConfig.uncaughtException = arg.ue
}

(!=null will only let it go through if the value is not null or undefined)

It also doesn't actually check for the value of uncaughtException, only the shorthand versions.

Node-Death SIGINT working fine on windows, but not gracefully shutting down services on Linux or MacOS platform

Hi Team,

Issue:
I'm using node-death in my project. Node-Death is working fine when I'm running my application in Windows platform. On 'SIGINT' (ctrl+c) its gracefully shutting down the open connections made in my application.
But when I issue 'SIGINT' signal from either MacOS or Linux platforms it, immediately shuts down the application without graceful shutdown of open connections. I have also used 'process.stdin.resume()' to prevent immediate shutdown, but still doesn't work.

Please find below my code:

import ON_DEATH from 'death';
import mongoose from './db.config';
import redisClient from './redis.config';
import { logger } from './pino.config';

const logError = (from, code, error) => {
    logger.error({ from, code, error });
};

const logInfo = connectionName => (logger.info({ message: `Connection with ${connectionName} shutdown gracefully!!!` }));

const shutdownRedis = () => redisClient.quit();

const shutdownMongoose = () => mongoose.connection.close(false);

// Begin reading from stdin so the process does not exit.
process.stdin.resume();

const onDeathCallback = async () => {
    try {
        await shutdownRedis();
        logInfo('Redis');
        await shutdownMongoose();
        logInfo('Mongo');
    } catch (err) {
        logError('death.config.onDeathCallback', 'ERR_GRACEFUL_CONN_SHUTDOWN', err);
    }
};

ON_DEATH(onDeathCallback);

Expected Output:
Connection with Redis shutdown gracefully!!!
Connection with Mongo shutdown gracefully!!!

Actual Output:
No output as it doesn't execute the callback

Please kindly let me know if I'm doing anything wrong with the configurations.
Looking forward to your help/reply on the above issue.

Thanks & Regards,
Siddharth

Fails with piping

$ node script.js | tee script.log
^Cevents.js:163
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at exports._errnoException (util.js:1050:11)
    at WriteWrap.afterWrite [as oncomplete] (net.js:814:14)

The script is:

var ON_DEATH = require('death'); //this is intentionally ugly

ON_DEATH(function(signal, err) { console.log('croak'); })

setTimeout(function () {}, 10000);

node-cleanup doesn't call my handler either, but at least doesn't display this ugly error message :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.