Permalink
Browse files

Loops script help fixes + more README stuff

  • Loading branch information...
1 parent fb09d67 commit d9768b83d9d99ebc5639b5cd3be94eb1339d41a0 @kovyrin committed Feb 16, 2009
Showing with 36 additions and 1 deletion.
  1. +35 −0 README.rdoc
  2. +1 −1 generators/loops/templates/script/loops
View
@@ -40,6 +40,41 @@ This will create the following list of files:
* ./app/loops/queue_loop.rb - simple ActiveMQ queue worker
+== How to use?
+
+Here is a simple loop scaffold for you to start from (put this file to app/loops/hello_world_loop.rb):
+
+ class HelloWorldLoop < Loops::Base
+ def run
+ with_period_of(1) do # period is in seconds
+ debug("Hello, debug log!")
+ sleep(config['sleep_period']) # Do something "useful" and make it configurable
+ debug("Hello, debug log (yes, once again)!")
+ end
+ end
+ end
+
+When you have your loop ready to use, add the following lines to your (maybe empty yet) config/loops.yml
+file:
+
+ hello_world:
+ type: simple
+ sleep_period: 10
+
+This is it! To start your loop, just run one of the following commands:
+
+* To list all configured loops:
+ $ ./script/loops -l
+* To run all enabled (actually non-disabled) loops in foreground:
+ $ ./script/loops
+* To run all enabled loops in background:
+ $ ./script/loops -d
+* To run specific loop in background:
+ $ ./script/loops -d -l hello_world
+* To see all possible options:
+ $ ./script/loops -h
+
+
== What Ruby implementations it works for?
We've tested and use the plugin on MRI 1.8.6 and on JRuby 1.1.5. At this point we do not support
@@ -32,7 +32,7 @@ opts = OptionParser.new do |opt|
opt.on('-l', '--loop=loop_name', 'Start specified loop(s) only') { |v| options[:loops] << v }
opt.on('-a', '--all', 'Start all loops') { |v| options[:all_loops] = v }
opt.on('-L', '--list', 'Shows all available loops with their options') { |v| options[:list_loops] = v }
- opt.on('-f', '--framework=name', 'Starts withing Rails (rails) or Merb (merb) framework') { |v| options[:framework] = v }
+ opt.on('-f', '--framework=name', 'Starts within a Rails (rails) or Merb (merb) project. Default is rails.') { |v| options[:framework] = v }
opt.on('-e', '--environment=env', 'Set RAILS_ENV (MERB_ENV) value') { |v| options[:environment] = v }
opt.on_tail("-h", "--help", "Show this message") do

0 comments on commit d9768b8

Please sign in to comment.