Skip to content

Commit

Permalink
tweak tweak tweak readme
Browse files Browse the repository at this point in the history
  • Loading branch information
billymeltdown committed Jan 21, 2009
1 parent ce06b5e commit 7af8fe8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.textile
@@ -1,8 +1,8 @@
Looper is a dead simple Ruby module for daemonizing your code, meant for use with Rails' script/runner. No forking involved, no detaching, simply running a nice healthy loop, but allowing your code to bail out of it, and making it responsive to signals.

You implement a class like "DoSomething" that checks for new message objects and then does something to them. This class will include Looper in order to easily loop, respond to shutdown signals, and it can then be run via script/runner as a daemon.
You implement a class like "DoSomething" that checks for new message objects and then does something to them. This class will include @Looper@ in order to easily loop, respond to shutdown signals, and it can then be run via script/runner as a daemon.

The loop handles sleeping between runs, and will catch any unhandled exceptions that bubble up and keep on truckin'. Thus, if you want to exit on a particular exception, you've got to rescue it in your code and set @\@run@ to @false@.
The loop handles sleeping between runs, and will catch any unhandled exceptions that bubble up and keep on truckin'. Thus, if you want to exit on a particular exception, you've got to rescue it in your code and set @@run@ to @false@.

Here's an example usage:

Expand Down Expand Up @@ -41,6 +41,6 @@ DoSomething.new( { :sleep => 10 } ).run

Now we can just kick that off any way we like and background the process, but we tend to use it with script/runner in our Rails environments to have access to our models and such. It boils down to:

$ nohup script/runner -e RAILS_ENV /path/to/DoSomething.rb
@$ nohup script/runner -e RAILS_ENV /path/to/DoSomething.rb@

And then looking up the PID by matching on /path/to/DoSomething.rb via grep and use kill to send the term signal.

0 comments on commit 7af8fe8

Please sign in to comment.