fate 0.2.18 → 0.2.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -56,16 +56,11 @@ class Fate
56
56
  end
57
57
 
58
58
  def stop
59
- ordered = @service.stop_order(manager.running)
60
- ordered.each do |name|
61
- manager.stop_command(name)
62
- end
59
+ manager.stop_all
63
60
  end
64
61
 
65
62
  def restart
66
63
  stop
67
- # FIXME: this is here to prevent redis-server from crying
68
- sleep 0.5
69
64
  start
70
65
  end
71
66
 
@@ -82,7 +77,7 @@ class Fate
82
77
  if manager.start_group(commands)
83
78
  logger.green "All commands in '#{command_spec}' running."
84
79
  else
85
- logger.red "Failed to start '#{command_spec}'."
80
+ logger.error "Failed to start '#{command_spec}'."
86
81
  end
87
82
  end
88
83
  end
@@ -19,14 +19,15 @@ class Fate
19
19
  @names_by_pid = {}
20
20
  @pids_by_name = {}
21
21
  at_exit do
22
- shutdown
22
+ stop_all
23
23
  end
24
24
  end
25
25
 
26
- def shutdown
26
+ def stop_all
27
27
  @mutex.synchronize do
28
- @names_by_pid.each do |pid, name|
29
- kill(name)
28
+ ordered = @service.stop_order(running)
29
+ ordered.each do |name|
30
+ term(name)
30
31
  end
31
32
  end
32
33
  end
@@ -52,22 +53,30 @@ class Fate
52
53
  end
53
54
  end
54
55
 
55
- def kill(name)
56
+ def stop_command(name)
57
+ term(name)
58
+ end
59
+
60
+ def term(name)
56
61
  if pid = @pids_by_name[name]
57
62
  @names_by_pid.delete(pid)
58
63
  @pids_by_name.delete(name)
59
64
  @threads.delete(name)
60
65
  system "kill -s TERM #{pid}"
61
66
  logger.info "Sent a kill signal to '#{name}' running at #{pid}"
67
+ begin
68
+ # Signal 0 checks for the process, but sends no signal.
69
+ Process.kill(0, pid)
70
+ rescue
71
+ # TODO: limit number of retries, possibly issue kill -9?
72
+ sleep 0.01
73
+ retry
74
+ end
62
75
  else
63
76
  logger.error "Could not find pid for '#{name}'"
64
77
  end
65
78
  end
66
79
 
67
- def stop_command(name)
68
- kill(name)
69
- end
70
-
71
80
  def spawn(name, command)
72
81
  return Thread.new do
73
82
 
@@ -155,7 +164,7 @@ class Fate
155
164
  end
156
165
  logger.info "Shutting down all processes."
157
166
 
158
- shutdown
167
+ stop_all
159
168
  exit(1)
160
169
  end
161
170
 
@@ -36,7 +36,7 @@ class Fate
36
36
  self.restart_command(args.first)
37
37
  end
38
38
 
39
- command("commands") do
39
+ command("processes") do
40
40
  puts self.service.names
41
41
  end
42
42
 
@@ -86,10 +86,10 @@ class Fate
86
86
  @completions ||= Set.new
87
87
  hash.each_path do |path, value|
88
88
  key = path.join(".")
89
- # add dot-delimited command names to the completions
90
- @completions += path.map {|s| s.to_s }
91
- @completions << key
92
- # register each command under the dot-delimited name
89
+ # add dot-delimited process names to the completions
90
+ (path.size).times do |i|
91
+ @completions << path.slice(0..i).join(".")
92
+ end
93
93
  out[key] = value
94
94
  end
95
95
  out
@@ -104,8 +104,9 @@ class Fate
104
104
  targets += resolve_commands(gname)
105
105
  end
106
106
  else
107
+ regex = /^#{name}\..*/
107
108
  @commands.each do |cname, _command|
108
- if cname.split(".").first == name
109
+ if cname =~ regex
109
110
  targets << cname
110
111
  end
111
112
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-04 00:00:00.000000000 Z
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.2.9
37
+ version: 0.2.10
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.2.9
45
+ version: 0.2.10
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: squeeze
48
48
  requirement: !ruby/object:Gem::Requirement