Backgroundrb works well on windows, but it does not work on my
production system(CentOS), it just prints out the follow log, but the
test worker has
never been call:( Very strange, any idea?
log:
DRb URI: druby://localhost:22222
Pid: 4327
Autostart…
test_worker
done
code:
class TestWorker < BackgrounDRb::Rails
repeat_every 1.minutes
first_run Time.now
def do_work(args)
puts “[test worker] do_work…”
end
end
yml:
port: “22222”
timer_sleep: 60
load_rails: true
environment: production
host: localhost
database_yml: config/database.yml
acl:
deny: all
allow: localhost 127.0.0.1
order: deny,allow
autostart:
test_worker:
class: test_worker
args: bar
On Sep 15, 2006, at 12:07 AM, cafebabe wrote:
done
code:
class TestWorker < BackgrounDRb::Rails
repeat_every 1.minutes
first_run Time.now
def do_work(args)
puts “[test worker] do_work…”
@logger.debug “[test worker] do_work…”
end
end
You can use puts in a worker like that. You need to use @logger.
-Ezra
Ezra Z. wrote:
On Sep 15, 2006, at 12:07 AM, cafebabe wrote:
done
code:
class TestWorker < BackgrounDRb::Rails
repeat_every 1.minutes
first_run Time.now
def do_work(args)
puts “[test worker] do_work…”
@logger.debug “[test worker] do_work…”
end
end
You can use puts in a worker like that. You need to use @logger.
-Ezra
resovled.
backgroundrb_rails.rb has a method:
def self.first_run(time)
class_eval <<-e
def schedule_first_run
Time.parse("#{time}")
end
e
end
to determin when to run workers,
Time.parse("#{time}") can not properly parse “#{Time.now}” on my centos
server,
it returns a time object 1 day from now, so my worker will started 1 day
later…
So I think
time.kind_of?(Time) ? time : Time.parse("#{time}")
would be better
And I found that althought the time zone on my centos server is
Asia/Shanghai,
but Time.now return a time object of CST, when I change the time zone to
Asia/Hong_Kong, it works well, crazy…