ryandotsmith / log-shuttle

New Repository: https://github.com/heroku/log-shuttle
https://github.com/heroku/log-shuttle
22 stars 6 forks source link

log-shuttle dies before reading stdin #19

Closed fabiokung closed 11 years ago

fabiokung commented 11 years ago

I'm trying to replace some uses of logger with log-shuttle. In this case, the code does something like:

echo "my log line" | logger -t ... -p ...

or:

def log(message)
  IO.popen("logger -t ... -p ...", "w") { |io| io.puts(message) }
end

log-shuttle fails to replace logger in this case, with no useful error message. I noticed that it doesn't even send the http request to the logplex server.

Playing with the code a little bit, I noticed that something like this makes it work:

def log(message)
  IO.popen("log-shuttle -logplex-token ... -procid ...", "w") do |io|
    sleep 1
    io.puts(message)
    sleep 2
  end
end

Apparently log-shuttle needs some time to be ready to read stdin, and is probably being killed by a SIGPIPE (SIGCHLD or something similar) before it gets a chance to read stdin and post the http message.

I also tried -batch-size=1 and low wait values, with no luck.

fabiokung commented 11 years ago

/cc @ryandotsmith

fabiokung commented 11 years ago

Thinking more about this, a new log-shuttle process (+ tcp connection + http request) for each log line is a bad idea. Closing this in favor of #20, which is a better way to support systems currently using logger.

ryandotsmith commented 11 years ago

@fabiokung , I have circled back around to this issue, and found that your example seems to work on the latest version of log-shuttle.

$ log-shuttle --version
0.2
CMD='log-shuttle -logs-url="https://east.logplex.io/logs" -logplex-token="t.abc123"'

def log(message)
  IO.popen(CMD, "w") { |io| io.puts(message) }
end

log('hello world')
fabiokung commented 11 years ago

@ryandotsmith thanks! I still don't think that this is a good idea, but it's good for simple testing and validation.