开发者

Rails daemon does not output any log info

I have a custom daemon in my Rails application. It is pretty simple (looks in the DB for "scheduled" jobs and "runs" them). This worked great in development and test environments but, of course, the daemon refuses to even start in production. To make matters worse, I can't seem to be able to get it to generate any log output so I'm not sure what's going wrong.

In fact, even in the development environment, the daemon didn't generate any log output. Here's my config/daemons.yml:

dir_mode: script
dir: ../../log
multiple: true
backtrace: true
monitor: true
log_output: true

And my lib/daemon/xyz_ctl:

#!/usr/local/bin/ruby
require 'rubygems'
require "daemons"
require 'yaml'
require 'erb'
require 'active_support'

options = YAML::load(
  ERB.new(
开发者_运维知识库  IO.read(
  File.dirname(__FILE__) + "/../../config/daemons.yml"
  )).result)
options["dir_mode"] = options["dir_mode"].to_sym

Daemons.run File.dirname(__FILE__) + '/xyz.rb', options

The log directory does not have anything other than the .log files and those don't get any output. Any ideas on how I can get this to even output some logging?


I still can't get the logging to work, but I did get the daemon to start in production. In the production environment I had both, v3.0.7 and v3.0.8 of actionmailer, actionpack, activemodel, activerecord, activeresource and activesupport. My dev VM only had 3.0.7.. Uninstalling the 3.0.8's helped. But the log-silence is still bothering me :(

Update: using logger in the daemon works in development mode (using info level) but not in production (I suspect because the production environment does not log info level messages by default? I haven't tested that yet).. Closing this for now :\


I have just had the same issue. The logger was not flushing by default in production.

Try adding the following to lib/daemons/xyz.rb - either after your Rails app is initialized if you need it, or in the while loop:

Rails.logger.auto_flushing = true

If you used the daemon generator you'll probably find that line is added by default and you deleted it at some point :o)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜