Permalink
Browse files

Demonstrating missing console messages in an async thread.

  • Loading branch information...
1 parent a296973 commit e60bb421f109194024dab19783ef885df376a8d0 @jcrossley3 jcrossley3 committed Apr 7, 2011
Showing with 33 additions and 0 deletions.
  1. +1 −0 service/Rakefile
  2. +4 −0 service/torquebox.yml
  3. +28 −0 service/waiter.rb
View
1 service/Rakefile
@@ -0,0 +1 @@
+require "torquebox-rake-support"
View
4 service/torquebox.yml
@@ -0,0 +1,4 @@
+
+services:
+ Waiter:
+ wait: 10
View
28 service/waiter.rb
@@ -0,0 +1,28 @@
+
+class Waiter
+ def initialize(opts)
+ @wait = opts['wait'].to_i
+ @logger = TorqueBox::Logger.new(self.class)
+ end
+ def start
+ log "starting"
+ run
+ end
+ def run
+ Thread.new do
+ while !@stopped do
+ log "time=#{Time.now}"
+ sleep @wait
+ wherearemystupiderrors
+ end
+ log "stopped waiting #@wait seconds"
+ end
+ end
+ def stop
+ log "stopping"
+ @stopped = true
+ end
+ def log(msg)
+ @logger.info(msg)
+ end
+end

0 comments on commit e60bb42

Please sign in to comment.