smith 0.8.6 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f41bf6879785fbde0dd04453174ad0d967ca749e
4
- data.tar.gz: 1e2e293379fc3b2032f33861dc3acf2b4fdb473a
3
+ metadata.gz: ece67408d7e69a0d140c6c71a829995ca2b3aa37
4
+ data.tar.gz: f8021c6a1f14de124f37dd5e7615cda0ea355815
5
5
  SHA512:
6
- metadata.gz: 9e2d8810f747b30c071486ddc77415d141cfe75857e1ca52e9c2292f7f086e2296b3c11e3aff95948804c6c9975d62875d3e212246df4819da63d2ec87b704ba
7
- data.tar.gz: 86f591c50199dc00a2bac2a8693b4da2e558f72888db7cf5b203b33fdea2bf9ac532f3b02b5f987bc035eef57967c08869c4b5116bab4c9c7ffc4f7ade8d28ee
6
+ metadata.gz: c001cd85c559a060809a20db61b62a50d3eeb87829e0f9c9efb1f601f21b1155bf79076964f163aa2f32c07d69628ff3e3ac13e8dbee6e856b5743221872aa6b
7
+ data.tar.gz: 527a5f514f80b67fddfd2ad9fdf1cd19f5529339e40c0c20b8588f93d8cbe90f170864d3857cb1077ffd244221ce4096662f787697c77cd3bf5e85624931aa31
@@ -106,7 +106,7 @@ Usage:
106
106
  # Setup signal handlers to clean up.
107
107
 
108
108
  %w{TERM INT QUIT}.each do |sig|
109
- signal_handler.install_signal_handler(sig) { @agency.stop }
109
+ signal_handler.install_signal_handler(sig) { Smith.stop(true) }
110
110
  end
111
111
 
112
112
  control.send_command(command, args) do |result|
@@ -21,6 +21,13 @@ kqueue = true
21
21
  pid_directory = "~/.smith/run"
22
22
  cache_directory = "~/.smith/cache"
23
23
 
24
+ # These directories get added to the Ruby $LOAD_PATH for agents to require code.
25
+ lib_directories = ["lib"]
26
+ # Shared codebase with a basic web app:
27
+ # lib_directories = ["lib", "app"]
28
+ # Shared codebase with a Rails app:
29
+ # lib_directories = ["lib", "app/models", "vendor"]
30
+
24
31
  # This is the directory that will contain the agent groups
25
32
  group_directory = "groups"
26
33
 
@@ -45,6 +45,10 @@ module Smith
45
45
  Pathname.new(__FILE__).dirname.parent.expand_path
46
46
  end
47
47
 
48
+ def lib_directories
49
+ config.agency.lib_directories
50
+ end
51
+
48
52
  def agent_directories
49
53
  config.agency.agent_directories
50
54
  end
@@ -170,7 +170,7 @@ module Smith
170
170
  # Start an agent. This forks and execs the bootstrapper class
171
171
  # which then becomes responsible for managing the agent process.
172
172
  def self.start_process(agent_process)
173
- fork do
173
+ pid = fork do
174
174
  # Detach from the controlling terminal
175
175
  unless Process.setsid
176
176
  raise 'Cannot detach from controlling terminal'
@@ -195,8 +195,10 @@ module Smith
195
195
  exec(binary, bootstrapper.to_s, agent_process.name, agent_process.uuid)
196
196
  end
197
197
 
198
+ logger.info { "Detaching: #{agent_process.name}, UUID: #{agent_process.uuid}, PID: #{pid}" }
199
+
198
200
  # We don't want any zombies.
199
- Process.detach(agent_process.pid)
201
+ Process.detach(pid)
200
202
  end
201
203
 
202
204
  # FIXME: This doesn't appear to be being called.
@@ -132,24 +132,26 @@ module Smith
132
132
  logger.error { "Terminating: #{@agent_name}, UUID: #{@agent_uuid}, PID: #{@pid.pid}." }
133
133
  end
134
134
 
135
- # Add the ../lib to the load path. This assumes the directory
136
- # structure is:
135
+ # Add directories with library code to the load path. This assumes that
136
+ # the required files reside at the same level as the agent directory.
137
+ #
138
+ # Always defaults to `lib` if a `lib_directories` list is not provided
139
+ # by the configuration.
137
140
  #
138
141
  # $ROOT_PATH/agents
139
142
  # .../lib
140
143
  #
141
- # where $ROOT_PATH can be anywhere.
142
- #
143
- # This needs to be better thought out.
144
- # TODO think this through some more.
144
+ # Where $ROOT_PATH is dependent on the agent directory.
145
145
  def add_agent_load_path(path)
146
146
  Smith.agent_directories.each do |path|
147
- lib_path = path.parent.join('lib')
148
- if lib_path.exist?
149
- logger.info { "Adding #{lib_path} to load path" }
150
- $LOAD_PATH << lib_path
151
- else
152
- logger.info { "No lib directory for: #{path.parent}." }
147
+ Smith.lib_directories.each do |lib_dir|
148
+ lib_path = path.parent.join(lib_dir)
149
+ if lib_path.exist?
150
+ logger.info { "Adding #{lib_path} to load path." }
151
+ $LOAD_PATH << lib_path
152
+ else
153
+ logger.info { "#{lib_dir} directory not found in: #{path.parent}." }
154
+ end
153
155
  end
154
156
  end
155
157
  end
@@ -1,3 +1,3 @@
1
1
  module Smith
2
- VERSION = "0.8.6"
2
+ VERSION = "0.8.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Heycock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amqp
@@ -104,6 +104,9 @@ dependencies:
104
104
  name: protobuf
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
107
110
  - - "~>"
108
111
  - !ruby/object:Gem::Version
109
112
  version: '3.4'
@@ -111,6 +114,9 @@ dependencies:
111
114
  prerelease: false
112
115
  version_requirements: !ruby/object:Gem::Requirement
113
116
  requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '3.0'
114
120
  - - "~>"
115
121
  - !ruby/object:Gem::Version
116
122
  version: '3.4'