senotrusov-ruby-process-controller 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -180,15 +180,15 @@ class ProcessController
|
|
180
180
|
if is_running? running_pid
|
181
181
|
raise "#{@name}: already running with pid #{running_pid}"
|
182
182
|
else
|
183
|
-
log(:warn
|
183
|
+
log(:warn){"#{self.class}#initialize @name:`#{@name}' -- Found pidfile:`#{@pid_file}' with pid:`#{running_pid}' and is not running, it may be result of an unclean shutdown."}
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
-
@logger.info "#{self.class}#initialize @name:`#{@name}' -- Creating process..."
|
187
|
+
@logger.info {"#{self.class}#initialize @name:`#{@name}' -- Creating process..."}
|
188
188
|
|
189
189
|
@daemon = yield(self)
|
190
190
|
|
191
|
-
@logger.info "#{self.class}#initialize @name:`#{@name}' -- Process initialized."
|
191
|
+
@logger.info {"#{self.class}#initialize @name:`#{@name}' -- Process initialized."}
|
192
192
|
end
|
193
193
|
|
194
194
|
if @argv["help"]
|
@@ -206,7 +206,7 @@ class ProcessController
|
|
206
206
|
|
207
207
|
rescue Exception => exception
|
208
208
|
begin
|
209
|
-
log(:fatal
|
209
|
+
log(:fatal){"#{self.class}#initialize @name:`#{@name}' -- #{exception.inspect_with_backtrace}"} if @log_file != STDOUT
|
210
210
|
|
211
211
|
unless @detached
|
212
212
|
@argv.errors << exception.inspect_with_backtrace
|
@@ -240,7 +240,7 @@ class ProcessController
|
|
240
240
|
end
|
241
241
|
|
242
242
|
def execute_run
|
243
|
-
@logger.info "#{self.class}#execute_run @name:`#{@name}' -- Starting..."
|
243
|
+
@logger.info {"#{self.class}#execute_run @name:`#{@name}' -- Starting..."}
|
244
244
|
|
245
245
|
create_pid
|
246
246
|
|
@@ -254,7 +254,7 @@ class ProcessController
|
|
254
254
|
ensure
|
255
255
|
untrap_signals
|
256
256
|
delete_pid
|
257
|
-
@logger.info "#{self.class}#execute_run @name:`#{@name}' -- Stopped"
|
257
|
+
@logger.info {"#{self.class}#execute_run @name:`#{@name}' -- Stopped"}
|
258
258
|
end
|
259
259
|
|
260
260
|
def daemon_start_sequence
|
@@ -275,7 +275,7 @@ class ProcessController
|
|
275
275
|
@daemon.start
|
276
276
|
end
|
277
277
|
rescue Exception => exception
|
278
|
-
log(:fatal
|
278
|
+
log(:fatal){"#{self.class}#start_daemon @name:`#{@name}' -- #{exception.inspect_with_backtrace}"}
|
279
279
|
stop_daemon
|
280
280
|
end
|
281
281
|
|
@@ -283,7 +283,7 @@ class ProcessController
|
|
283
283
|
def join_daemon
|
284
284
|
@daemon.join if @daemon.respond_to?(:join) && @daemon_started_to_some_extent
|
285
285
|
rescue Exception => exception
|
286
|
-
log(:fatal
|
286
|
+
log(:fatal){"#{self.class}#join_daemon @name:`#{@name}' -- #{exception.inspect_with_backtrace}"}
|
287
287
|
end
|
288
288
|
|
289
289
|
|
@@ -292,7 +292,7 @@ class ProcessController
|
|
292
292
|
@daemon.before_exit if @daemon.respond_to?(:before_exit) && @daemon_started_to_some_extent
|
293
293
|
end
|
294
294
|
rescue Exception => exception
|
295
|
-
log(:fatal
|
295
|
+
log(:fatal){"#{self.class}#before_exit_daemon_handler @name:`#{@name}' -- #{exception.inspect_with_backtrace}"}
|
296
296
|
end
|
297
297
|
|
298
298
|
|
@@ -383,7 +383,7 @@ class ProcessController
|
|
383
383
|
def stop_thread
|
384
384
|
Thread.new_with_exception_handling(lambda { Process.exit!(FAILURE_EXIT_CODES[:stop_thread]) }, @logger, :fatal, "#{self.class}#stop_thread") do
|
385
385
|
Thread.stop
|
386
|
-
@logger.debug
|
386
|
+
@logger.debug {"#{self.class}#stop_thread @name:`#{@name}' -- Stopping..."}
|
387
387
|
@daemon_mutex.synchronize do
|
388
388
|
@must_terminate = true
|
389
389
|
@daemon.stop if @daemon_started_to_some_extent
|
@@ -395,14 +395,14 @@ class ProcessController
|
|
395
395
|
stop_daemon
|
396
396
|
rescue Exception => exception
|
397
397
|
begin
|
398
|
-
log(:fatal
|
398
|
+
log(:fatal){"#{self.class}#dispatch_termination_signal @name:`#{@name}' -- Error while stopping: #{exception.inspect_with_backtrace}"}
|
399
399
|
ensure
|
400
400
|
Process.exit!(FAILURE_EXIT_CODES[:dispatch_termination_signal])
|
401
401
|
end
|
402
402
|
end
|
403
403
|
|
404
404
|
def stop_daemon
|
405
|
-
log(:info
|
405
|
+
log(:info) {"\n#{self.class}#stop_daemon @name:`#{@name}' -- Stopping..."}
|
406
406
|
|
407
407
|
if @termination_watchdog
|
408
408
|
begin
|
@@ -476,9 +476,9 @@ class ProcessController
|
|
476
476
|
|
477
477
|
# LOGGING
|
478
478
|
|
479
|
-
def log severity,
|
479
|
+
def log severity, &block
|
480
480
|
if defined?(@logger)
|
481
|
-
@logger.__send__(severity,
|
481
|
+
@logger.__send__(severity, &block)
|
482
482
|
@logger.flush if @logger.respond_to?(:flush)
|
483
483
|
end
|
484
484
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: senotrusov-ruby-process-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislav Senotrusov
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|