Commit 93fcfd9 1 parent 6488edf commit 93fcfd9 Copy full SHA for 93fcfd9
File tree 2 files changed +28
-7
lines changed
2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -3,18 +3,27 @@ require 'rubygems' unless defined?(Gem)
3
3
require 'bundler/setup'
4
4
require 'forever'
5
5
6
- Forever . run :fork => ENV [ 'FORK' ] do
6
+ Forever . run :fork => !! ENV [ 'FORK' ] do
7
7
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" )
9
10
10
- before :each do
11
+ before :all do
11
12
puts 'before all'
12
13
end
13
14
14
- after :each do
15
+ before :each do
16
+ puts 'before each'
17
+ end
18
+
19
+ after :all do
15
20
puts 'after all'
16
21
end
17
22
23
+ after :each do
24
+ puts 'after each'
25
+ end
26
+
18
27
every 1 . seconds do
19
28
puts 'wait me 10 seconds'
20
29
sleep 10
@@ -24,10 +33,20 @@ Forever.run :fork => ENV['FORK'] do
24
33
puts 'every 2 seconds'
25
34
end
26
35
36
+ every 10 . seconds do
37
+ raise 'Arg....'
38
+ end
39
+
27
40
on_ready do
28
41
puts "All jobs will will wait me for 1 second" ; sleep 1
29
42
end
30
43
44
+ on_error do |e |
45
+ puts '-' * 30
46
+ puts e
47
+ puts '-' * 30
48
+ end
49
+
31
50
on_exit do
32
51
puts "Bye bye"
33
52
end
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def initialize(options={}, &block)
27
27
exit
28
28
when 'start' , 'restart' , 'up' , nil
29
29
stop
30
- when 'run'
30
+ when 'run' , 'live'
31
31
detach = false
32
32
stop
33
33
when 'stop'
@@ -50,6 +50,7 @@ def initialize(options={}, &block)
50
50
Commands:
51
51
52
52
start stop (if present) the daemon and perform a start
53
+ live run in no-deamon mode
53
54
stop stop the daemon if a during when it is idle
54
55
restart same as start
55
56
kill force stop by sending a KILL signal to the process
@@ -332,7 +333,8 @@ def to_s
332
333
end
333
334
alias :inspect :to_s
334
335
335
- private
336
+ private
337
+
336
338
def filters
337
339
@_filters ||= {
338
340
:before => { :each => [ ] , :all => [ ] } ,
@@ -351,7 +353,7 @@ def maybe_fork(detach,&block)
351
353
yield
352
354
end
353
355
end
354
-
356
+
355
357
def write_config!
356
358
config_was = File . exist? ( FOREVER_PATH ) ? YAML . load_file ( FOREVER_PATH ) : [ ]
357
359
config_was . delete_if { |conf | conf . nil? || conf . empty? || conf [ :file ] == file }
You can’t perform that action at this time.
0 commit comments