Skip to content

Commit 93fcfd9

Browse files
committed
Fixing examples and few whitespaces.
1 parent 6488edf commit 93fcfd9

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

examples/simple

+23-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,27 @@ require 'rubygems' unless defined?(Gem)
33
require 'bundler/setup'
44
require 'forever'
55

6-
Forever.run :fork => ENV['FORK'] do
6+
Forever.run :fork => !!ENV['FORK'] do
77
dir File.expand_path('../', __FILE__) # Default is ../../__FILE__
8-
queue 2
8+
log File.join(dir, "#{name}.log")
9+
pid File.join(dir, "#{name}.pid")
910

10-
before :each do
11+
before :all do
1112
puts 'before all'
1213
end
1314

14-
after :each do
15+
before :each do
16+
puts 'before each'
17+
end
18+
19+
after :all do
1520
puts 'after all'
1621
end
1722

23+
after :each do
24+
puts 'after each'
25+
end
26+
1827
every 1.seconds do
1928
puts 'wait me 10 seconds'
2029
sleep 10
@@ -24,10 +33,20 @@ Forever.run :fork => ENV['FORK'] do
2433
puts 'every 2 seconds'
2534
end
2635

36+
every 10.seconds do
37+
raise 'Arg....'
38+
end
39+
2740
on_ready do
2841
puts "All jobs will will wait me for 1 second"; sleep 1
2942
end
3043

44+
on_error do |e|
45+
puts '-' * 30
46+
puts e
47+
puts '-' * 30
48+
end
49+
3150
on_exit do
3251
puts "Bye bye"
3352
end

lib/forever/base.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize(options={}, &block)
2727
exit
2828
when 'start', 'restart', 'up', nil
2929
stop
30-
when 'run'
30+
when 'run', 'live'
3131
detach = false
3232
stop
3333
when 'stop'
@@ -50,6 +50,7 @@ def initialize(options={}, &block)
5050
Commands:
5151
5252
start stop (if present) the daemon and perform a start
53+
live run in no-deamon mode
5354
stop stop the daemon if a during when it is idle
5455
restart same as start
5556
kill force stop by sending a KILL signal to the process
@@ -332,7 +333,8 @@ def to_s
332333
end
333334
alias :inspect :to_s
334335

335-
private
336+
private
337+
336338
def filters
337339
@_filters ||= {
338340
:before => { :each => [], :all => [] },
@@ -351,7 +353,7 @@ def maybe_fork(detach,&block)
351353
yield
352354
end
353355
end
354-
356+
355357
def write_config!
356358
config_was = File.exist?(FOREVER_PATH) ? YAML.load_file(FOREVER_PATH) : []
357359
config_was.delete_if { |conf| conf.nil? || conf.empty? || conf[:file] == file }

0 commit comments

Comments
 (0)