scout_agent 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,14 @@
1
+ == 3.1.5
2
+
3
+ * Fixed a bug that could cause the agent to crash when shutting down if running
4
+ with --no-daemon
5
+ * Switched DNS strategies so slow DNS resolving doesn't kill our background
6
+ threading for process monitoring
7
+ * Relaxed the process monitoring timeout to ten seconds
8
+ * Relaxed TERM to KILL timeouts to five seconds
9
+ * Unwound some metaprogramming magic so some missing methods would show up in
10
+ the documentation
11
+
1
12
  == 3.1.4
2
13
 
3
14
  * Modified the API to no longer load the JSON gem if we already have JSON
@@ -157,7 +157,7 @@ module ScoutAgent
157
157
  # if the process has not yet exited. The exit code for the process is
158
158
  # returned if it can be determined (+nil+ is returned otherwise).
159
159
  #
160
- def term_or_kill(child_pid, pause = 1)
160
+ def term_or_kill(child_pid, pause = 5)
161
161
  %w[TERM KILL].each { |signal|
162
162
  begin
163
163
  ::Process.kill(signal, child_pid) # attempt to stop process
@@ -12,7 +12,7 @@ module ScoutAgent
12
12
  # The number of seconds allowed to pass before the Agent subprocess is
13
13
  # considered unresponsive.
14
14
  #
15
- NO_CONTACT_TIMEOUT = 5
15
+ NO_CONTACT_TIMEOUT = 10
16
16
  #
17
17
  # The frequency with which the subprocess is expected to check-in. This is
18
18
  # purposely set to a little under a second to give one more check-in
@@ -23,7 +23,7 @@ module ScoutAgent
23
23
  # The number of seconds the monitor will wait for a process to exit cleanly
24
24
  # before forcing a stop.
25
25
  #
26
- TERM_TO_KILL_PAUSE = 1
26
+ TERM_TO_KILL_PAUSE = 5
27
27
  #
28
28
  # The sequence of seconds this monitor will wait between restarts of the
29
29
  # subprocess. The initial values are short, to try and get running again as
@@ -97,11 +97,13 @@ module ScoutAgent
97
97
  @launch_and_monitor_thread.exit if @launch_and_monitor_thread
98
98
  # ask child process to exit
99
99
  log.info("Asking '#{@agent}' to stop.")
100
- IDCard.new(@agent).signal("TERM")
100
+ begin
101
+ IDCard.new(@agent).signal("TERM")
102
+ rescue Errno::ESRCH # no such process
103
+ # if already exited, so we are fine
104
+ end
101
105
  end
102
106
  end
103
- rescue Errno::ESRCH # no such process
104
- # if already exited, so we are fine
105
107
  end
106
108
 
107
109
  #
@@ -299,14 +299,24 @@ module ScoutAgent
299
299
  Pathname.new(super)
300
300
  end
301
301
 
302
- #
303
- # This code defines OS specific path accessors that honor the +prefix_path+.
304
- # These paths prefix all of the specific application paths.
305
- #
306
- %w[os_config_path os_db_path os_pid_path os_log_path].each do |path|
307
- define_method(path) {
308
- prefix_path + super()
309
- }
302
+ # The configuarion path for your operation system, using prefix_path().
303
+ def os_config_path
304
+ prefix_path + super
305
+ end
306
+
307
+ # The database path for your operation system, using prefix_path().
308
+ def os_db_path
309
+ prefix_path + super
310
+ end
311
+
312
+ # The PID file path for your operation system, using prefix_path().
313
+ def os_pid_path
314
+ prefix_path + super
315
+ end
316
+
317
+ # The log path for your operation system, using prefix_path().
318
+ def os_log_path
319
+ prefix_path + super
310
320
  end
311
321
 
312
322
  #
@@ -317,36 +327,59 @@ module ScoutAgent
317
327
  os_config_path + (super || "#{ScoutAgent.agent_name}.rb")
318
328
  end
319
329
 
330
+ # The database path for this agent, using prefix_path() and os_db_path().
331
+ def db_dir
332
+ os_db_path + (super || ScoutAgent.agent_name)
333
+ end
334
+
335
+ # The PID file path for this agent, using prefix_path() and os_pid_path().
336
+ def pid_dir
337
+ os_pid_path + (super || ScoutAgent.agent_name)
338
+ end
339
+
340
+ # The log path for this agent, using prefix_path() and os_log_path().
341
+ def log_dir
342
+ os_log_path + (super || ScoutAgent.agent_name)
343
+ end
344
+
345
+ #
346
+ # Builds the database directory for this agent, owned by +group_id+ but with
347
+ # full privileges for all.
348
+ #
349
+ def build_db_dir(group_id)
350
+ build_dir(:db_dir, 0777, group_id)
351
+ end
352
+
320
353
  #
321
- # This code defines the application specific directory paths, prefixed by
322
- # +prefix_path+ and the related OS directory. By default, these directories
323
- # are named after the agent.
354
+ # Builds the PID file directory for this agent, owned by +group_id+ but
355
+ # readable by all.
324
356
  #
325
- %w[db pid log].each do |path|
326
- define_method("#{path}_dir") {
327
- send("os_#{path}_path") + (super() || ScoutAgent.agent_name)
328
- }
357
+ def build_pid_dir(group_id)
358
+ build_dir(:pid_dir, 0775, group_id)
329
359
  end
330
360
 
331
361
  #
332
- # This code creates builders for the configuration directories. These
333
- # methods build the directories and set their group and permissons so
334
- # they can be written to after the daemon surrenders super user privileges.
362
+ # Builds the log directory for this agent, owned by +group_id+ but with full
363
+ # privileges for all.
335
364
  #
336
- { :db_dir => 0777,
337
- :pid_dir => 0775,
338
- :log_dir => 0777 }.each do |path, permissions|
339
- define_method("build_#{path}") { |group_id|
340
- begin
341
- send(path).mkpath
342
- send(path).chown(nil, group_id)
343
- send(path).chmod(permissions)
344
- true
345
- rescue Errno::EACCES, Errno::EPERM # don't have permission
346
- false
347
- end
348
- }
365
+ def build_log_dir(group_id)
366
+ build_dir(:log_dir, 0777, group_id)
367
+ end
368
+
369
+ #
370
+ # Creates +path+, sets the +group_id+ for it, and gives it +permissions+.
371
+ # Returns +true+ if all of that succeeds, +false+ otherwise (due to
372
+ # permission issues).
373
+ #
374
+ def build_dir(path, permissions, group_id)
375
+ send(path).mkpath
376
+ send(path).chown(nil, group_id)
377
+ send(path).chmod(permissions)
378
+ true
379
+ rescue Errno::EACCES, Errno::EPERM # don't have permission
380
+ false
349
381
  end
382
+ private :build_dir
350
383
 
351
384
  #############
352
385
  ### URL's ###
data/lib/scout_agent.rb CHANGED
@@ -33,6 +33,10 @@ require_lib_or_gem "rest_client", "=0.9.2"
33
33
  require_lib_or_gem "xmpp4r", "=0.4"
34
34
  require_lib_or_gem "xmpp4r/roster" # loads from xmpp4r's version
35
35
 
36
+ # *IMPORTANT*: make sure slow DNS requests don't kill our background threading
37
+ require "resolv-replace"
38
+ Socket.do_not_reverse_lookup = true
39
+
36
40
  # The namespace for all agent software.
37
41
  module ScoutAgent
38
42
  # Returns the name of the agent executable.
@@ -91,7 +95,7 @@ module ScoutAgent
91
95
  end
92
96
 
93
97
  # The version of this agent.
94
- VERSION = "3.1.4".freeze
98
+ VERSION = "3.1.5".freeze
95
99
  # A Pathname reference to the agent code directory, used in dynamic loading.
96
100
  LIB_DIR = Pathname.new(File.dirname(__FILE__)) + agent_name
97
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Edward Gray II
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-05-08 00:00:00 -05:00
15
+ date: 2009-05-12 00:00:00 -05:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency