god
god copied to clipboard
log does not write until process is stopped
the log file does not get written to when god process is running in the background until i killed the process.
here is my command for running god: ruby /home/alex/.rvm/gems/ruby-2.1.2/bin/god -c streaming_watcher.god
here is my streaming_watcher.god:
God.watch do |w|
w.name = "streaming_watcher"
w.start = "/home/alex/.rvm/rubies/ruby-2.1.2/bin/ruby /home/alex/removed/bin/streaming_watcher.rb"
w.log = "/home/alex/removed/log/streaming_watcher.log"
w.env = { 'RAILS_ROOT' => "/home/alex/removed", 'RAILS_ENV' => "production" }
w.keepalive
end
the file /home/alex/removed/log/streaming_watcher.log has nothing added to it if i watch it via tail -f until i kill the god process. then everything gets written to it...
This isn't something I've seen before.
My best guess is the logger you're using isn't flushing to STDOUT until you exit the process.
yeah, i get that, but im not doing anything except using puts in the rb script im running.
do i need to manually call $stdout.flush or something?
Could you try adding STDOUT.sync = true to the top of your script?
yeah, that worked. may want to document this :+1:
just got this in my log file: /usr/bin/env: ruby_executable_hooks: No such file or directory
I would guess that you're running into something rvm-related and I'm not going to be much help there. sorry.
yah, googled it... http://stackoverflow.com/questions/18936933/bundle-update-env-ruby-executable-hooks-no-such-file-or-directory
I've landed here while looking for solution to the same problem but completely unrelated to this Gem, I'm using basic Ruby's Logger and I had to add the second line on this snippet for it to work:
file = File.open('/var/log/thisistotallyalogfile.log', File::WRONLY | File::APPEND | File::CREAT)
file.sync = true
logger = Logger.new(file, 'daily')
logger.level = Logger::INFO
decided to try after the STDOUT.sync = true comment if the same would apply to the file handler and it did :)