daemonizer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/daemonizer.gemspec +1 -1
- data/lib/daemonizer/cli.rb +14 -4
- data/lib/daemonizer/engine.rb +17 -18
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/daemonizer.gemspec
CHANGED
data/lib/daemonizer/cli.rb
CHANGED
@@ -71,10 +71,20 @@ module Daemonizer
|
|
71
71
|
invoke :start, pool_name
|
72
72
|
end
|
73
73
|
|
74
|
-
desc "
|
75
|
-
def
|
76
|
-
|
77
|
-
|
74
|
+
desc "debug", "Debug pool (do not demonize)"
|
75
|
+
def debug(pool_name = nil)
|
76
|
+
puts "You should supply pool_name to debug" if pool_name.nil?
|
77
|
+
control_pools_loop(pool_name, "execution ended", options[:demfile]) do |pool|
|
78
|
+
STDOUT.sync = true
|
79
|
+
print_pool pool.name, "Debugging pool: "
|
80
|
+
|
81
|
+
engine = Engine.new(pool)
|
82
|
+
engine.debug!
|
83
|
+
|
84
|
+
print_pool pool.name, " Done!"
|
85
|
+
exit(0)
|
86
|
+
end
|
87
|
+
return true end
|
78
88
|
|
79
89
|
private
|
80
90
|
def control_pools_loop(pool_name, message = nil, demfile = nil, &block)
|
data/lib/daemonizer/engine.rb
CHANGED
@@ -2,7 +2,7 @@ module Daemonizer
|
|
2
2
|
class Engine
|
3
3
|
attr_reader :config
|
4
4
|
|
5
|
-
def initialize(config)
|
5
|
+
def initialize(config, debug = false)
|
6
6
|
@config = config
|
7
7
|
end
|
8
8
|
|
@@ -19,14 +19,14 @@ module Daemonizer
|
|
19
19
|
@config.after_init.call(logger, process_id, @config.workers)
|
20
20
|
end
|
21
21
|
rescue Exception => e
|
22
|
-
logger.fatal
|
22
|
+
logger.fatal e.to_s
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
begin
|
27
27
|
@config.before_init.call(@config.logger, init_block)
|
28
28
|
rescue Exception => e
|
29
|
-
logger.fatal
|
29
|
+
logger.fatal e.to_s
|
30
30
|
end
|
31
31
|
# Start monitoring loop
|
32
32
|
|
@@ -34,25 +34,24 @@ module Daemonizer
|
|
34
34
|
@pm.monitor_workers
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
@pm = Daemonizer::ProcessManager.new(global_config, Daemonizer.logger)
|
40
|
-
loop_config = loops_config[loop_name] || {}
|
37
|
+
def debug!
|
38
|
+
logger.outputters = Outputter.stdout
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
puts "Can't load loop class!"
|
49
|
-
return false
|
40
|
+
init_block = Proc.new do
|
41
|
+
begin
|
42
|
+
@config.after_init.call(logger, 1, 1)
|
43
|
+
rescue Exception => e
|
44
|
+
logger.fatal e.to_s
|
45
|
+
end
|
50
46
|
end
|
51
47
|
|
52
|
-
|
53
|
-
|
48
|
+
begin
|
49
|
+
@config.before_init.call(@config.logger, init_block)
|
50
|
+
rescue Exception => e
|
51
|
+
logger.fatal e.to_s
|
52
|
+
end
|
54
53
|
end
|
55
|
-
|
54
|
+
|
56
55
|
private
|
57
56
|
def setup_signals
|
58
57
|
stop = proc {
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daemonizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gleb Pomykalov
|