billymeltdown-looper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.textile +3 -3
  2. data/lib/looper.rb +2 -2
  3. data/looper.gemspec +1 -1
  4. metadata +1 -1
data/README.textile CHANGED
@@ -1,8 +1,8 @@
1
1
  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.
2
2
 
3
- 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.
3
+ 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.
4
4
 
5
- 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@.
5
+ 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@.
6
6
 
7
7
  Here's an example usage:
8
8
 
@@ -41,6 +41,6 @@ DoSomething.new( { :sleep => 10 } ).run
41
41
 
42
42
  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:
43
43
 
44
- $ nohup script/runner -e RAILS_ENV /path/to/DoSomething.rb
44
+ @$ nohup script/runner -e RAILS_ENV /path/to/DoSomething.rb@
45
45
 
46
46
  And then looking up the PID by matching on /path/to/DoSomething.rb via grep and use kill to send the term signal.
data/lib/looper.rb CHANGED
@@ -43,10 +43,10 @@ module Looper
43
43
 
44
44
  puts "#{Time.now} process started with #{run_every} loop. kill #{Process.pid} to stop"
45
45
 
46
- last_run = Time.now - run_every.seconds - 1
46
+ last_run = Time.now - run_every - 1
47
47
  while (@run) do
48
48
  now = Time.now
49
- if last_run + run_every.seconds < now
49
+ if last_run + run_every < now
50
50
  begin
51
51
  yield
52
52
  rescue Exception => e
data/looper.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "looper"
3
- s.version = "0.0.1"
3
+ s.version = "0.0.2"
4
4
  s.date = "2009-01-21"
5
5
  s.summary = "Module for really simple daemons"
6
6
  s.email = "wgray@zetetic.net"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billymeltdown-looper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Billy Gray