Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevents program from exiting #24

Closed
notslang opened this issue Apr 22, 2015 · 5 comments · May be fixed by Wizcorp/node-graylog2#10
Closed

prevents program from exiting #24

notslang opened this issue Apr 22, 2015 · 5 comments · May be fixed by Wizcorp/node-graylog2#10

Comments

@notslang
Copy link
Contributor

Since this never calls close on the graylog2 UDP stream, this transport prevents the program from exiting when it's finished.

Here's some code I'm using to test:

winston = require('winston')
Graylog = require('winston-graylog2')

log = new(winston.Logger)(
  transports: [
    new (winston.transports.Console)(
      handleExceptions: true
    ),
    new(Graylog)(
      silent: false,
      handleExceptions: true,
      graylog:
        servers: [{host: '104.236.18.71', port: 12201}],
        bufferSize: 1400
    )
  ]
)

log.info('test')
@notslang
Copy link
Contributor Author

A super hacky workaround for this would be reaching into the graylog2 package & calling unref() on its client... something like

setTimeout(( -> log.transports.graylog2.graylog2.client.unref()), 100)

But it needs to be run after the client has been created, which we can't determine reliably. Maybe this should be an issue with the graylog2 package

@unlucio
Copy link
Contributor

unlucio commented Apr 29, 2015

hi @slang800 :)
yes, we saw that too but never really found an elegant way to make it happen yet :(
I saw you opened a PR to node-graylog2. I'll take a look and see if I can give an hand there :)

cheers

@odino
Copy link
Contributor

odino commented Apr 29, 2015

@slang800 thumbs up if you want to give this a crack..we've been banging our head against it as well :)

@odino
Copy link
Contributor

odino commented Dec 20, 2015

BTW we could do the same thing that's done in https://github.com/kenperkins/winston-papertrail#closing-the-transport

@frehner
Copy link

frehner commented Mar 27, 2017

A potentially interesting note is how this affects AWS Lambda functions, since they'll just time out instead of terminating -- and since you're charged for how long your Lambda function runs, it could cost you a bit more than you expect.

@odino odino closed this as completed in f6c950e Sep 19, 2017
odino added a commit that referenced this issue Sep 19, 2017
Close Graylog2 connection on close. Fixes #24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants