seamusabshere-daemon-spawn 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/daemon_spawn.rb +4 -3
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/daemon_spawn.rb
CHANGED
@@ -40,7 +40,7 @@ module DaemonSpawn
|
|
40
40
|
STDIN.reopen "/dev/null"
|
41
41
|
STDOUT.reopen log
|
42
42
|
STDERR.reopen STDOUT
|
43
|
-
trap(
|
43
|
+
trap(daemon.signal) {daemon.stop; exit}
|
44
44
|
daemon.start(args)
|
45
45
|
end
|
46
46
|
puts "#{daemon.app_name} started."
|
@@ -49,7 +49,7 @@ module DaemonSpawn
|
|
49
49
|
def self.stop(daemon) #:nodoc:
|
50
50
|
if pid = daemon.pid
|
51
51
|
FileUtils.rm(daemon.pid_file)
|
52
|
-
Process.kill(
|
52
|
+
Process.kill(daemon.signal, pid)
|
53
53
|
begin
|
54
54
|
Process.wait(pid)
|
55
55
|
rescue Errno::ECHILD
|
@@ -66,10 +66,11 @@ module DaemonSpawn
|
|
66
66
|
end
|
67
67
|
|
68
68
|
class Base
|
69
|
-
attr_accessor :log_file, :pid_file, :sync_log, :working_dir, :app_name, :singleton, :index
|
69
|
+
attr_accessor :log_file, :pid_file, :sync_log, :working_dir, :app_name, :singleton, :index, :signal
|
70
70
|
|
71
71
|
def initialize(opts = {})
|
72
72
|
raise 'You must specify a :working_dir' unless opts[:working_dir]
|
73
|
+
self.signal = opts[:signal] || "TERM"
|
73
74
|
self.working_dir = opts[:working_dir]
|
74
75
|
self.app_name = opts[:application] || classname
|
75
76
|
self.pid_file = opts[:pid_file] || File.join(working_dir, 'tmp', 'pids', app_name + extension)
|