質問

I'm running a worker dyno on Heroku that uses rufus-scheduler to do some work.

During the work it will log some messages to the console (using simple puts), however these messages are only unreliably transfered to the Heroku log and Add-ons like Logentries.

When I restart the dyno all missing console messages are printed on the console before the process exits. Is this behaviour related to some buffering? How can I circumvent this? Or is it related to rufus-scheduler spawning the work in Threads?

I've read something about options to prevent buffering for Rack-based apps in the Heroku documentation but not for worker dynos.

Regards Stefan

役に立ちましたか?

解決

Just read https://devcenter.heroku.com/articles/logging#writing-to-your-log

I guess you're simply writing to the console. Have you tried to add

$stdout.sync = true
$stderr.sync = true # eventually

to your config.ru or at the head of your app?

Instead of setting sync to true globally, you could also try and do

puts "logging... hello world..."
puts "oh and, this is what happened"
$stdout.flush

flush after each piece of logging, but that's boring.

If you don't log that way please explain in your question and don't count on your readers' divination abilities.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top