serverengine 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ 2013-06-11 version 1.5.2:
3
+
4
+ * Updated default parameters of ProcessManager to be more conservative
5
+ * Daemon: added :daemonize_error_exit_code option
6
+ * Fixed ServerEngine.create
7
+
8
+
2
9
  2013-06-04 version 1.5.1:
3
10
 
4
11
  * Changed #close callback to #after_start
data/README.md CHANGED
@@ -326,6 +326,7 @@ Graceful shutdown and restart call `Worker#stop` method and wait for completion
326
326
  - **chuser** changes execution user (not dynamic reloadable)
327
327
  - **chgroup** changes execution group (not dynamic reloadable)
328
328
  - **chumask** changes umask (not dynamic reloadable)
329
+ - **daemonize_error_exit_code** exit code when daemonize, changing user or changing group fails (default: 1) (not dynamic reloadable)
329
330
  - Supervisor: available only when `supervisor` parameters is true
330
331
  - **server_process_name** changes process name ($0) of server process (not dynamic reloadable)
331
332
  - **restart_server_process** restarts server process when it receives USR1 or HUP signal. (default: false) (not dynamic reloadable)
@@ -340,14 +341,14 @@ Graceful shutdown and restart call `Worker#stop` method and wait for completion
340
341
  - **start_worker_delay_rand** randomizes start_worker_delay at this ratio (default: 0.2)
341
342
  - Multiprocess server: available only when `worker_type` is "process"
342
343
  - **worker_process_name** changes process name ($0) of workers
343
- - **worker_heartbeat_interval**
344
- - **worker_heartbeat_timeout**
345
- - **worker_graceful_kill_interval**
346
- - **worker_graceful_kill_interval_increment**
347
- - **worker_graceful_kill_timeout**
348
- - **worker_immediate_kill_interval**
349
- - **worker_immediate_kill_interval_increment**
350
- - **worker_immediate_kill_timeout**
344
+ - **worker_heartbeat_interval** sets interval of heartbeats in seconds (default: 1.0)
345
+ - **worker_heartbeat_timeout** sets timeout of heartbeat in seconds (default: 180)
346
+ - **worker_graceful_kill_interval** sets the first interval of TERM signals in seconds (default: 15)
347
+ - **worker_graceful_kill_interval_increment** sets increment of TERM signal interval in seconds (default: 10)
348
+ - **worker_graceful_kill_timeout** sets promotion timeout from TERM to QUIT signal in seconds. -1 means no timeout (default: 600)
349
+ - **worker_immediate_kill_interval** sets the first interval of QUIT signals in seconds (default: 10)
350
+ - **worker_immediate_kill_interval_increment** sets increment of QUIT signal interval in seconds (default: 10)
351
+ - **worker_immediate_kill_timeout** sets promotion timeout from QUIT to KILL signal in seconds. -1 means no timeout (default: 600)
351
352
  - Logger
352
353
  - **log** sets path to log file. Set "-" for STDOUT (default: STDERR)
353
354
  - **log_level** log level: debug, info, warn, error or fatal. (default: debug)
data/lib/serverengine.rb CHANGED
@@ -47,6 +47,6 @@ module ServerEngine
47
47
  }
48
48
 
49
49
  def self.create(server_module, worker_module, load_config_proc={}, &block)
50
- Daemon.new(server_module, worker_module, load_config_proc={}, &block)
50
+ Daemon.new(server_module, worker_module, load_config_proc, &block)
51
51
  end
52
52
  end
@@ -41,6 +41,7 @@ module ServerEngine
41
41
  end
42
42
 
43
43
  @daemon_process_name = @config[:daemon_process_name]
44
+ @daemonize_error_exit_code = @config[:daemonize_error_exit_code] || 1
44
45
 
45
46
  @pid_path = @config[:pid_path]
46
47
  @chuser = @config[:chuser]
@@ -63,7 +64,7 @@ module ServerEngine
63
64
  chgid = group.to_i
64
65
  if chgid.to_s != group
65
66
  chgid = `id -g #{Shellwords.escape group}`.to_i
66
- exit! 1 unless $?.success?
67
+ exit! @daemonize_error_exit_code unless $?.success?
67
68
  end
68
69
  Process::GID.change_privilege(chgid)
69
70
  end
@@ -72,11 +73,11 @@ module ServerEngine
72
73
  chuid = user.to_i
73
74
  if chuid.to_s != user
74
75
  chuid = `id -u #{Shellwords.escape user}`.to_i
75
- exit! 1 unless $?.success?
76
+ exit! @daemonize_error_exit_code unless $?.success?
76
77
  end
77
78
 
78
79
  user_groups = `id -G #{Shellwords.escape user}`.split.map(&:to_i)
79
- exit! 1 unless $?.success?
80
+ exit! @daemonize_error_exit_code unless $?.success?
80
81
 
81
82
  Process.groups = Process.groups | user_groups
82
83
  Process::UID.change_privilege(chuid)
@@ -90,7 +91,7 @@ module ServerEngine
90
91
  exit main
91
92
  rescue
92
93
  ServerEngine.dump_uncaught_error($!)
93
- exit 1 # TODO exit code
94
+ exit @daemonize_error_exit_code
94
95
  end
95
96
  end
96
97
 
@@ -133,7 +134,7 @@ module ServerEngine
133
134
 
134
135
  exit 0
135
136
  ensure
136
- exit! 1 # TODO exit code
137
+ exit! @daemonize_error_exit_code
137
138
  end
138
139
  end
139
140
 
@@ -148,7 +149,7 @@ module ServerEngine
148
149
 
149
150
  data = rpipe.read
150
151
  if data != "\n"
151
- return 1 # TODO exit code
152
+ return @daemonize_error_exit_code
152
153
  end
153
154
 
154
155
  return 0
@@ -62,13 +62,13 @@ module ServerEngine
62
62
 
63
63
  CONFIG_PARAMS = {
64
64
  heartbeat_interval: 1,
65
- heartbeat_timeout: 60,
66
- graceful_kill_interval: 2,
67
- graceful_kill_interval_increment: 2,
68
- graceful_kill_timeout: -1,
69
- immediate_kill_interval: 2,
70
- immediate_kill_interval_increment: 2,
71
- immediate_kill_timeout: 60,
65
+ heartbeat_timeout: 180,
66
+ graceful_kill_interval: 15,
67
+ graceful_kill_interval_increment: 10,
68
+ graceful_kill_timeout: 600,
69
+ immediate_kill_interval: 10,
70
+ immediate_kill_interval_increment: 10,
71
+ immediate_kill_timeout: 600,
72
72
  }
73
73
 
74
74
  attr_reader :graceful_kill_signal, :immediate_kill_signal
@@ -303,7 +303,7 @@ module ServerEngine
303
303
  if !@immediate_kill_start_time
304
304
  # check escalation
305
305
  if heartbeat_delay >= @pm.heartbeat_timeout ||
306
- (@graceful_kill_start_time && @pm.graceful_kill_timeout > 0 &&
306
+ (@graceful_kill_start_time && @pm.graceful_kill_timeout >= 0 &&
307
307
  @graceful_kill_start_time < now - @pm.graceful_kill_timeout)
308
308
  # escalate to immediate kill
309
309
  @kill_count = 0
@@ -322,7 +322,8 @@ module ServerEngine
322
322
  if @immediate_kill_start_time
323
323
  interval = @pm.immediate_kill_interval
324
324
  interval_incr = @pm.immediate_kill_interval_increment
325
- if @immediate_kill_start_time <= now - @pm.immediate_kill_timeout
325
+ if @pm.immediate_kill_timeout >= 0 &&
326
+ @immediate_kill_start_time <= now - @pm.immediate_kill_timeout
326
327
  # escalate to SIGKILL
327
328
  signal = :KILL
328
329
  else
@@ -1,3 +1,3 @@
1
1
  module ServerEngine
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
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-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sigdump
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: 2571011204453974309
120
+ hash: 3345901740562467160
121
121
  requirements: []
122
122
  rubyforge_project:
123
123
  rubygems_version: 1.8.23