From 9b3779b91967e4460425ef731aba2c5be829a877 Mon Sep 17 00:00:00 2001 From: Alexey Kovyrin Date: Mon, 15 Mar 2010 19:18:34 -0400 Subject: [PATCH] Spaces cleanup --- README.rdoc | 105 ++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/README.rdoc b/README.rdoc index 69cd2c5..508132f 100755 --- a/README.rdoc +++ b/README.rdoc @@ -1,35 +1,35 @@ = Simple background loops framework -loops is a small and lightweight framework for Ruby on Rails, Merb and other ruby -frameworks created to support simple background loops in your application which are usually -used to do some background data processing on your servers (queue workers, batch tasks +loops is a small and lightweight framework for Ruby on Rails, Merb and other ruby +frameworks created to support simple background loops in your application which are usually +used to do some background data processing on your servers (queue workers, batch tasks processors, etc). _Warning_: If you use some pre-2.0 version of this plugin, read a dedicated paragraph below. - + == What would you use it for? -Originally loops plugin was created to make our own loops code a bit more organized. We used -to have dozens of different modules with methods that were called with script/runner and then -used with nohup and other painful backgrounding techniques. When you have such a number of -loops/workers to run in background it becomes a nightmare to manage them on a regular basis +Originally loops plugin was created to make our own loops code a bit more organized. We used +to have dozens of different modules with methods that were called with script/runner and then +used with nohup and other painful backgrounding techniques. When you have such a number of +loops/workers to run in background it becomes a nightmare to manage them on a regular basis (restarts, code upgrades, status/health checking, etc). -After a few takes on writing our scripts in a more organized way we were able to generalize most -of the code so now our loops started looking like a classes with a single mandatory public method -called *run*. Everything else (spawning many workers, managing them, logging, backgrounding, +After a few takes on writing our scripts in a more organized way we were able to generalize most +of the code so now our loops started looking like a classes with a single mandatory public method +called *run*. Everything else (spawning many workers, managing them, logging, backgrounding, pid-files management, etc) is handled by the plugin itself. == But there are dozens of libraries like this! Why do we need yet another one? -The major idea behind this small project was to create a deadly simple and yet robust framework to -be able to run some tasks in background and do not think about spawning many workers, restarting -them when they die, etc. So, if you need to be able to run either one or many copies of your worker -and you do not want to think about re-spawning your scripts when they die and you do not want to -spend megabytes of RAM on separate copies of Ruby interpreter (when you run each copy of your -loop as a separate process controlled by monit/god/etc), then you should try this framework -- +The major idea behind this small project was to create a deadly simple and yet robust framework to +be able to run some tasks in background and do not think about spawning many workers, restarting +them when they die, etc. So, if you need to be able to run either one or many copies of your worker +and you do not want to think about re-spawning your scripts when they die and you do not want to +spend megabytes of RAM on separate copies of Ruby interpreter (when you run each copy of your +loop as a separate process controlled by monit/god/etc), then you should try this framework -- you're going to like it. @@ -40,7 +40,7 @@ There are two options when approaching db-charmer installation: * using the gem (recommended) * install as a Rails plugin -To install as a gem, add this to your environment.rb: +To install as a gem, add this to your environment.rb: config.gem 'loops' @@ -56,10 +56,10 @@ This will install the whole package in your vendor/plugins directory. For merb applications, just check out the code and place it to the vendor/plugins directory. -After you are done with the installation, you need to generate binary and configuration +After you are done with the installation, you need to generate binary and configuration files by running: - ./script/generate loops + ./script/generate loops This will create the following list of files: * ./script/loops - binary file that will be used to manage your loops @@ -70,7 +70,7 @@ This will create the following list of files: == How to use? -Here is a simple loop scaffold for you to start from (put this file to +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 @@ -83,7 +83,7 @@ Here is a simple loop scaffold for you to start from (put this file to end end -When you have your loop ready to use, add the following lines to your (maybe empty yet) +When you have your loop ready to use, add the following lines to your (maybe empty yet) config/loops.yml file: hello_world: @@ -113,7 +113,7 @@ This is it! To manage your loop, just run one of the following commands: $ ./script/loops help -_Notice:_ If you use loops as a gem, you will get a system binary called loops which you +_Notice:_ If you use loops as a gem, you will get a system binary called loops which you could use instead of your ./script/loops binary: $ loops help @@ -121,18 +121,18 @@ could use instead of your ./script/loops binary: == How to run more than one worker? -If you want to have more than one copy of your worker running, that is as simple as adding one +If you want to have more than one copy of your worker running, that is as simple as adding one option to your loop configuration: hello_world: type: simple sleep_period: 10 - workers_number: 1 + workers_number: 1 -This workers_number option would tell loops manager to spawn more than one copy of -your loop and run them in parallel. The only thing you'd need to do is to remember about -concurrent work of your loops. For example, if you have some kind of database table with elements -you need to process, you can create a simple database-based locks system or use any +This workers_number option would tell loops manager to spawn more than one copy of +your loop and run them in parallel. The only thing you'd need to do is to remember about +concurrent work of your loops. For example, if you have some kind of database table with elements +you need to process, you can create a simple database-based locks system or use any memcache-based locks. @@ -151,7 +151,7 @@ the loop class to execute: loop_name: some_module/my_worker language: French -Now two independent sets of loops are using the same class SomeModule::MyWorkerLoop +Now two independent sets of loops are using the same class SomeModule::MyWorkerLoop customized by the language parameter. @@ -167,9 +167,9 @@ We use monit to keep loop monitors runnings. You could use something like this i == ActiveMQ-based workers? What's that? -In some of our worker loops we poll ActiveMQ queue and process its items to perform some -asynchronous operations. So, to make it simpler for us to create such a workers, we've created -really simple loops class extension that wraps your code with basic queue polling/acknowledging +In some of our worker loops we poll ActiveMQ queue and process its items to perform some +asynchronous operations. So, to make it simpler for us to create such a workers, we've created +really simple loops class extension that wraps your code with basic queue polling/acknowledging code and as the result, you can create a loops like this: class MyQueueLoop < Loops::Queue @@ -190,21 +190,21 @@ With configs like this: port: 61613 queue_name: blah -Of course, this solution scales perfectly and to make your queue processing faster you just +Of course, this solution scales perfectly and to make your queue processing faster you just need to add more workers (by adding workers_number: N option). -_Warning_: This type of loops requires you to have the stomp gem installed in your +_Warning_: This type of loops requires you to have the stomp gem installed in your system. == There is this workers_engine option in the config file. What do you use it for? -There are two so called "workers engines" in loops: fork and thread. -They're used to control the way process manager would spawn new loops workers: -with the fork engine we'll load all the loops classes and then fork ruby interpreter -as many times as many workers we need. With the thread engine we'd do Thread.new -instead of forking. Thread engine could be useful if you are sure your loop won't lock -ruby interpreter (it does not do native calls, etc) or if you use some interpreter that does +There are two so called "workers engines" in loops: fork and thread. +They're used to control the way process manager would spawn new loops workers: +with the fork engine we'll load all the loops classes and then fork ruby interpreter +as many times as many workers we need. With the thread engine we'd do Thread.new +instead of forking. Thread engine could be useful if you are sure your loop won't lock +ruby interpreter (it does not do native calls, etc) or if you use some interpreter that does not support forks (like jruby). The default engine is fork. @@ -212,26 +212,27 @@ The default engine is fork. == What Ruby implementations does it work for? -We've tested and used the plugin on MRI 1.8.6/1.8.7 and on JRuby 1.4.0. At this point we do -not support demonization in JRuby and never tested the code on Ruby 1.9. Obviously because -of JVM limitations you won't be able to use fork workers engine in JRuby, but +We've tested and used the plugin on MRI 1.8.6/1.8.7 and on JRuby 1.4.0. At this point we do +not support demonization in JRuby and never tested the code on Ruby 1.9. Obviously because +of JVM limitations you won't be able to use fork workers engine in JRuby, but threaded workers do pretty well. == Migrating from pre-2.0 releases -Before version 2.0 has been released, this code was developed as a Rails plugin only and -did not have any versions numbering system in place. So we call all those old versions -a pre-2.0 releases. If you use one of those relases (if your loops plugin does not have -the VERSION.yml file in the root directory), be careful when upgrading because -there are a few incompatible changes we have made in the loops command: -h, --a, -s, -L and -l options were deprecated -and replaced with a friendlier word commands. Use loops help to get help. +Before version 2.0 has been released, this code was developed as a Rails plugin only and +did not have any versions numbering system in place. So we call all those old versions +a pre-2.0 releases. If you use one of those relases (if your loops plugin does not have +the VERSION.yml file in the root directory), be careful when upgrading because +there are a few incompatible changes we have made in the loops command: -h, +-a, -s, -L and -l options were deprecated +and replaced with a friendlier word commands. +Use loops help to get help. == Who are the authors? -This plugin has been created in Scribd.com for our internal use and then the sources were opened +This plugin has been created in Scribd.com for our internal use and then the sources were opened for other people to use. All the code in this package has been developed by Alexey Kovyrin, Dmytro Shteflyuk and Alexey Verkhovsky for Scribd.com and is released under the MIT license. For more details, see LICENSE file.