daemons 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -4
- data/Rakefile +3 -8
- data/Releases +10 -0
- data/examples/run/ctrl_keep_pid_files.rb +17 -0
- data/examples/run/ctrl_proc_multiple.rb +22 -0
- data/examples/run/ctrl_proc_multiple.rb.output +2 -0
- data/examples/run/myserver_crashing.rb.output +15 -0
- data/lib/daemons.rb +13 -10
- data/lib/daemons/application.rb +43 -20
- data/lib/daemons/application_group.rb +3 -1
- data/lib/daemons/monitor.rb +2 -2
- data/lib/daemons/pid.rb +1 -1
- data/lib/daemons/pidfile.rb +24 -13
- metadata +45 -40
- data/test/call_as_daemon.rb +0 -12
- data/test/tc_main.rb +0 -24
- data/test/test1.rb +0 -19
- data/test/testapp.rb +0 -11
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Daemons Version 1.0.
|
1
|
+
= Daemons Version 1.0.10
|
2
2
|
|
3
3
|
(See Releases for release-specific information)
|
4
4
|
|
@@ -184,12 +184,11 @@ The RDoc documentation is also online at http://daemons.rubyforge.org
|
|
184
184
|
|
185
185
|
== Author
|
186
186
|
|
187
|
-
Written in 2005-
|
188
|
-
Homepage: http://physiker.ch
|
187
|
+
Written in 2005-2008 by Thomas Uehlinger <mailto:th.uehlinger@gmx.ch>.
|
189
188
|
|
190
189
|
== License
|
191
190
|
|
192
|
-
Copyright (c) 2005-
|
191
|
+
Copyright (c) 2005-2008 Thomas Uehlinger
|
193
192
|
|
194
193
|
Permission is hereby granted, free of charge, to any person
|
195
194
|
obtaining a copy of this software and associated documentation
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
Gem::manage_gems
|
3
3
|
|
4
4
|
require 'rake/gempackagetask'
|
5
|
-
require 'rake/testtask'
|
5
|
+
#require 'rake/testtask'
|
6
6
|
require 'rake/packagetask'
|
7
7
|
require 'rake/rdoctask'
|
8
8
|
|
@@ -16,7 +16,7 @@ PKG_FILES = FileList[
|
|
16
16
|
"Rakefile", "Releases", "TODO", "README", "LICENSE",
|
17
17
|
"setup.rb",
|
18
18
|
"lib/**/*.rb",
|
19
|
-
"test/**/*",
|
19
|
+
#"test/**/*",
|
20
20
|
"examples/**/*"
|
21
21
|
]
|
22
22
|
#PKG_FILES.exclude(%r(^test/tmp/.+))
|
@@ -48,7 +48,6 @@ spec = Gem::Specification.new do |s|
|
|
48
48
|
s.files = PKG_FILES
|
49
49
|
s.require_path = "lib"
|
50
50
|
s.autorequire = "daemons"
|
51
|
-
s.test_file = "test/tc_main.rb"
|
52
51
|
s.has_rdoc = true
|
53
52
|
s.extra_rdoc_files = ["README", "Releases", "TODO"]
|
54
53
|
end
|
@@ -67,11 +66,8 @@ end
|
|
67
66
|
#end
|
68
67
|
|
69
68
|
|
70
|
-
task :default => [:
|
69
|
+
task :default => [:package]
|
71
70
|
|
72
|
-
Rake::TestTask.new(:test) do |t|
|
73
|
-
t.test_files = FileList['test/tc_*.rb']
|
74
|
-
end
|
75
71
|
|
76
72
|
task :upload do
|
77
73
|
sh "scp -r html/* uehli@rubyforge.org:/var/www/gforge-projects/daemons"
|
@@ -85,5 +81,4 @@ rd = Rake::RDocTask.new("rdoc") { |rdoc|
|
|
85
81
|
rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README'
|
86
82
|
rdoc.rdoc_files.include('README', 'TODO', 'Releases')
|
87
83
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
88
|
-
rdoc.rdoc_files.include('test/**/*.rb')
|
89
84
|
}
|
data/Releases
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
= Daemons Release History
|
2
2
|
|
3
|
+
== Release 1.0.10: November 16, 2007
|
4
|
+
|
5
|
+
* By default, we now delete stray pid-files (i.e. pid-files which result for
|
6
|
+
example from a killed daemon) automatically. This function can be deactivated by
|
7
|
+
passing :keep_pid_files => true as an option.
|
8
|
+
* All pid files of :multiple daemons new get deleted correctly upon exit of the daemons (reported by Han Holl).
|
9
|
+
* Use the signal 'KILL' instead of 'TERM' on Windows platforms.
|
10
|
+
* Use exit! in trap('TERM') instead of exit when option :hard_exit is given (thanks to Han Holl).
|
11
|
+
* Did some clarification on the exception log.
|
12
|
+
|
3
13
|
== Release 1.0.9: October 29, 2007
|
4
14
|
|
5
15
|
* fixed a severe bug in the new Pid.running? function: function returned true if the process did not exist (thanks to Jeremy Lawler).
|
@@ -0,0 +1,17 @@
|
|
1
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
|
2
|
+
|
3
|
+
if File.exist?(File.join(lib_dir, 'daemons.rb'))
|
4
|
+
$LOAD_PATH.unshift lib_dir
|
5
|
+
else
|
6
|
+
begin; require 'rubygems'; rescue ::Exception; end
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'daemons'
|
10
|
+
|
11
|
+
|
12
|
+
options = {
|
13
|
+
:keep_pid_files => true
|
14
|
+
}
|
15
|
+
|
16
|
+
|
17
|
+
Daemons.run(File.join(File.dirname(__FILE__), 'myserver.rb'), options)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
|
2
|
+
|
3
|
+
if File.exist?(File.join(lib_dir, 'daemons.rb'))
|
4
|
+
$LOAD_PATH.unshift lib_dir
|
5
|
+
else
|
6
|
+
begin; require 'rubygems'; rescue ::Exception; end
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'daemons'
|
10
|
+
|
11
|
+
|
12
|
+
options = {
|
13
|
+
:log_output => true,
|
14
|
+
:multiple => true,
|
15
|
+
}
|
16
|
+
|
17
|
+
|
18
|
+
Daemons.run_proc('ctrl_proc_multiple.rb', options) do
|
19
|
+
puts "hello"
|
20
|
+
sleep(5)
|
21
|
+
puts "done"
|
22
|
+
end
|
@@ -13,3 +13,18 @@
|
|
13
13
|
ping from myserver.rb!
|
14
14
|
this example server will crash in 3 seconds...
|
15
15
|
CRASH!
|
16
|
+
ping from myserver.rb!
|
17
|
+
this example server will crash in 3 seconds...
|
18
|
+
CRASH!
|
19
|
+
/Users/uehli/Projects/daemons-proj/examples/run/myserver_crashing.rb:13: CRASH! (RuntimeError)
|
20
|
+
from /Users/uehli/Projects/daemons-proj/examples/run/myserver_crashing.rb:6:in `loop'
|
21
|
+
from /Users/uehli/Projects/daemons-proj/examples/run/myserver_crashing.rb:6
|
22
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons/application.rb:176:in `load'
|
23
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons/application.rb:176:in `start_load'
|
24
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons/application.rb:257:in `start'
|
25
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons/controller.rb:69:in `run'
|
26
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons.rb:139:in `run'
|
27
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons/cmdline.rb:105:in `call'
|
28
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons/cmdline.rb:105:in `catch_exceptions'
|
29
|
+
from /Users/uehli/Projects/daemons-proj/lib/daemons.rb:138:in `run'
|
30
|
+
from ctrl_crash.rb:17
|
data/lib/daemons.rb
CHANGED
@@ -38,7 +38,7 @@ require 'daemons/controller'
|
|
38
38
|
#
|
39
39
|
# == What does daemons internally do with my daemons?
|
40
40
|
# *or*:: why do my daemons crash when they try to open a file?
|
41
|
-
# *or*:: why can I not see any output from the daemon on the console (when using for example +puts
|
41
|
+
# *or*:: why can I not see any output from the daemon on the console (when using for example +puts+)?
|
42
42
|
#
|
43
43
|
# From a technical aspect of view, daemons does the following when creating a daemon:
|
44
44
|
#
|
@@ -48,7 +48,7 @@ require 'daemons/controller'
|
|
48
48
|
# 3. Forks another child process and exits first child. This prevents
|
49
49
|
# the potential of acquiring a controlling terminal.
|
50
50
|
# 4. Changes the current working directory to "/".
|
51
|
-
# 5. Clears the file creation mask (sets +umask+ to
|
51
|
+
# 5. Clears the file creation mask (sets +umask+ to 0000).
|
52
52
|
# 6. Closes file descriptors (reopens +STDOUT+ and +STDERR+ to point to a logfile if
|
53
53
|
# possible).
|
54
54
|
#
|
@@ -65,7 +65,7 @@ require 'daemons/controller'
|
|
65
65
|
#
|
66
66
|
module Daemons
|
67
67
|
|
68
|
-
VERSION = "1.0.
|
68
|
+
VERSION = "1.0.10"
|
69
69
|
|
70
70
|
require 'daemons/daemonize'
|
71
71
|
|
@@ -90,6 +90,9 @@ module Daemons
|
|
90
90
|
# and log files. Defaults to the basename of
|
91
91
|
# the script.
|
92
92
|
# <tt>:ARGV</tt>:: An array of strings containing parameters and switches for Daemons.
|
93
|
+
# This includes both parameters for Daemons itself and the controlled scripted.
|
94
|
+
# These are assumed to be separated by an array element '--', .e.g.
|
95
|
+
# ['start', 'f', '--', 'param1_for_script', 'param2_for_script'].
|
93
96
|
# If not given, ARGV (the parameters given to the Ruby process) will be used.
|
94
97
|
# <tt>:dir_mode</tt>:: Either <tt>:script</tt> (the directory for writing the pid files to
|
95
98
|
# given by <tt>:dir</tt> is interpreted relative
|
@@ -107,23 +110,23 @@ module Daemons
|
|
107
110
|
# <tt>:backtrace</tt>:: Write a backtrace of the last exceptions to the file '[app_name].log' in the
|
108
111
|
# pid-file directory if the application exits due to an uncaught exception
|
109
112
|
# <tt>:monitor</tt>:: Monitor the programs and restart crashed instances
|
110
|
-
# <tt>:log_output</tt>:: When given (i.e. set to true), redirect both STDOUT and STDERR to a logfile
|
111
|
-
#
|
112
|
-
#
|
113
|
+
# <tt>:log_output</tt>:: When given (i.e. set to true), redirect both STDOUT and STDERR to a logfile named '[app_name].output' in the pid-file directory
|
114
|
+
# <tt>:keep_pid_files</tt>:: When given do not delete lingering pid-files (files for which the process is no longer running).
|
115
|
+
# <tt>:hard_exit</tt>:: When given use exit! to end a daemons instead of exit (this will for example
|
116
|
+
# not call at_exit handlers).
|
113
117
|
# -----
|
114
118
|
#
|
115
119
|
# === Example:
|
116
120
|
# options = {
|
117
121
|
# :app_name => "my_app",
|
118
|
-
# :ARGV => ['start', '-f']
|
122
|
+
# :ARGV => ['start', '-f', '--', 'param_for_myscript']
|
119
123
|
# :dir_mode => :script,
|
120
124
|
# :dir => 'pids',
|
121
125
|
# :multiple => true,
|
122
126
|
# :ontop => true,
|
123
127
|
# :mode => :exec,
|
124
128
|
# :backtrace => true,
|
125
|
-
# :monitor => true
|
126
|
-
# :script => "path/to/script.rb"
|
129
|
+
# :monitor => true
|
127
130
|
# }
|
128
131
|
#
|
129
132
|
# Daemons.run(File.join(File.dirname(__FILE__), 'myscript.rb'), options)
|
@@ -173,7 +176,7 @@ module Daemons
|
|
173
176
|
options[:mode] = :proc
|
174
177
|
options[:proc] = block
|
175
178
|
|
176
|
-
# we do not have a script location so the the :script
|
179
|
+
# we do not have a script location so the the :script :dir_mode cannot be used, change it to :normal
|
177
180
|
if [nil, :script].include? options[:dir_mode]
|
178
181
|
options[:dir_mode] = :normal
|
179
182
|
options[:dir] = File.expand_path('.')
|
data/lib/daemons/application.rb
CHANGED
@@ -19,6 +19,9 @@ module Daemons
|
|
19
19
|
attr_reader :options
|
20
20
|
|
21
21
|
|
22
|
+
SIGNAL = (RUBY_PLATFORM =~ /win32/ ? 'KILL' : 'TERM')
|
23
|
+
|
24
|
+
|
22
25
|
def initialize(group, add_options = {}, pid = nil)
|
23
26
|
@group = group
|
24
27
|
@options = group.options.dup
|
@@ -85,15 +88,23 @@ module Daemons
|
|
85
88
|
# Note that the applications is not supposed to overwrite the signal handler for
|
86
89
|
# 'TERM'.
|
87
90
|
#
|
88
|
-
trap(
|
91
|
+
trap(SIGNAL) {
|
89
92
|
begin; @pid.cleanup; rescue ::Exception; end
|
90
93
|
$daemons_sigterm = true
|
91
94
|
|
92
|
-
|
95
|
+
if options[:hard_exit]
|
96
|
+
exit!
|
97
|
+
else
|
98
|
+
exit
|
99
|
+
end
|
93
100
|
}
|
94
101
|
end
|
95
102
|
|
96
103
|
def start_exec
|
104
|
+
if options[:backtrace]
|
105
|
+
puts "option :backtrace is not supported with :mode => :exec, ignoring"
|
106
|
+
end
|
107
|
+
|
97
108
|
unless options[:ontop]
|
98
109
|
Daemonize.daemonize(output_logfile, @group.app_name)
|
99
110
|
else
|
@@ -106,6 +117,8 @@ module Daemons
|
|
106
117
|
ENV['DAEMONS_ARGV'] = @controller_argv.join(' ')
|
107
118
|
# haven't tested yet if this is really passed to the exec'd process...
|
108
119
|
|
120
|
+
|
121
|
+
|
109
122
|
Kernel.exec(script(), *(@app_argv || []))
|
110
123
|
#Kernel.exec(script(), *ARGV)
|
111
124
|
end
|
@@ -141,11 +154,15 @@ module Daemons
|
|
141
154
|
# Note that the applications is not supposed to overwrite the signal handler for
|
142
155
|
# 'TERM'.
|
143
156
|
#
|
144
|
-
trap(
|
157
|
+
trap(SIGNAL) {
|
145
158
|
begin; @pid.cleanup; rescue ::Exception; end
|
146
159
|
$daemons_sigterm = true
|
147
160
|
|
148
|
-
|
161
|
+
if options[:hard_exit]
|
162
|
+
exit!
|
163
|
+
else
|
164
|
+
exit
|
165
|
+
end
|
149
166
|
}
|
150
167
|
|
151
168
|
# Now we really start the script...
|
@@ -161,8 +178,8 @@ module Daemons
|
|
161
178
|
|
162
179
|
def start_proc
|
163
180
|
return unless p = options[:proc]
|
164
|
-
|
165
|
-
myproc = proc do
|
181
|
+
|
182
|
+
myproc = proc do
|
166
183
|
# We need this to remove the pid-file if the applications exits by itself.
|
167
184
|
# Note that <tt>at_text</tt> will only be run if the applications exits by calling
|
168
185
|
# <tt>exit</tt>, and not if it calls <tt>exit!</tt> (so please don't call <tt>exit!</tt>
|
@@ -184,11 +201,15 @@ module Daemons
|
|
184
201
|
# Note that the applications is not supposed to overwrite the signal handler for
|
185
202
|
# 'TERM'.
|
186
203
|
#
|
187
|
-
trap(
|
204
|
+
trap(SIGNAL) {
|
188
205
|
begin; @pid.cleanup; rescue ::Exception; end
|
189
206
|
$daemons_sigterm = true
|
190
207
|
|
191
|
-
|
208
|
+
if options[:hard_exit]
|
209
|
+
exit!
|
210
|
+
else
|
211
|
+
exit
|
212
|
+
end
|
192
213
|
}
|
193
214
|
|
194
215
|
p.call()
|
@@ -270,17 +291,19 @@ module Daemons
|
|
270
291
|
|
271
292
|
l_file = Logger.new(logfile)
|
272
293
|
|
273
|
-
# the code below
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
294
|
+
# the code below finds the last exception
|
295
|
+
e = nil
|
296
|
+
|
297
|
+
ObjectSpace.each_object {|o|
|
298
|
+
if ::Exception === o
|
299
|
+
e = o
|
300
|
+
end
|
301
|
+
}
|
302
|
+
|
303
|
+
l_file.info "*** below you find the most recent exception thrown, this will be likely (but not certainly) the exception that made the application exit abnormally ***"
|
304
|
+
l_file.error e
|
305
|
+
|
306
|
+
l_file.info "*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***"
|
284
307
|
|
285
308
|
# this code logs every exception found in memory
|
286
309
|
ObjectSpace.each_object {|o|
|
@@ -304,7 +327,7 @@ module Daemons
|
|
304
327
|
# restarted by the monitor yet. By catching the error, we allow the
|
305
328
|
# pid file clean-up to occur.
|
306
329
|
begin
|
307
|
-
Process.kill(
|
330
|
+
Process.kill(SIGNAL, @pid.pid)
|
308
331
|
rescue Errno::ESRCH => e
|
309
332
|
puts "#{e} #{@pid.pid}"
|
310
333
|
puts "deleting pid-file."
|
@@ -41,6 +41,8 @@ module Daemons
|
|
41
41
|
@dir_mode = options[:dir_mode] || :script
|
42
42
|
@dir = options[:dir] || ''
|
43
43
|
|
44
|
+
@keep_pid_files = options[:keep_pid_files] || false
|
45
|
+
|
44
46
|
#@applications = find_applications(pidfile_dir())
|
45
47
|
@applications = []
|
46
48
|
end
|
@@ -58,7 +60,7 @@ module Daemons
|
|
58
60
|
end
|
59
61
|
|
60
62
|
def find_applications(dir)
|
61
|
-
pid_files = PidFile.find_files(dir, app_name)
|
63
|
+
pid_files = PidFile.find_files(dir, app_name, ! @keep_pid_files)
|
62
64
|
|
63
65
|
#pp pid_files
|
64
66
|
|
data/lib/daemons/monitor.rb
CHANGED
@@ -6,7 +6,7 @@ module Daemons
|
|
6
6
|
class Monitor
|
7
7
|
|
8
8
|
def self.find(dir, app_name)
|
9
|
-
pid = PidFile.find_files(dir, app_name)[0]
|
9
|
+
pid = PidFile.find_files(dir, app_name, false)[0]
|
10
10
|
|
11
11
|
if pid
|
12
12
|
pid = PidFile.existing(pid)
|
@@ -116,7 +116,7 @@ module Daemons
|
|
116
116
|
|
117
117
|
|
118
118
|
def stop
|
119
|
-
begin; Process.kill(
|
119
|
+
begin; Process.kill(Application::SIGNAL, @pid.pid); rescue ::Exception; end
|
120
120
|
|
121
121
|
# We try to remove the pid-files by ourselves, in case the application
|
122
122
|
# didn't clean it up.
|
data/lib/daemons/pid.rb
CHANGED
@@ -39,7 +39,7 @@ module Daemons
|
|
39
39
|
# break
|
40
40
|
# }
|
41
41
|
# ensure
|
42
|
-
# begin; begin; ps_in.close; rescue ::Exception; end; ps_out.close rescue
|
42
|
+
# begin; begin; ps_in.close; rescue ::Exception; end; begin; ps_out.close; rescue ::Exception; end; ps_err.close; rescue ::Exception; end
|
43
43
|
# end
|
44
44
|
#
|
45
45
|
# # an alternative would be to use the code below, but I don't know whether this is portable
|
data/lib/daemons/pidfile.rb
CHANGED
@@ -21,7 +21,7 @@ module Daemons
|
|
21
21
|
#
|
22
22
|
# Each file just contains one line with the pid as string (for example <tt>6432</tt>).
|
23
23
|
#
|
24
|
-
# === Where are Pid-Files stored?
|
24
|
+
# === Where are the Pid-Files stored?
|
25
25
|
#
|
26
26
|
# Daemons is configurable to store the Pid-Files relative to three different locations:
|
27
27
|
# 1. in a directory relative to the directory where the script (the one that is supposed to run
|
@@ -33,11 +33,22 @@ module Daemons
|
|
33
33
|
|
34
34
|
attr_reader :dir, :progname, :multiple, :number
|
35
35
|
|
36
|
-
def PidFile.find_files(dir, progname)
|
36
|
+
def PidFile.find_files(dir, progname, delete = false)
|
37
37
|
files = Dir[File.join(dir, "#{progname}*.pid")]
|
38
38
|
|
39
39
|
files.delete_if {|f| not (File.file?(f) and File.readable?(f))}
|
40
|
-
|
40
|
+
if delete
|
41
|
+
files.delete_if do |f|
|
42
|
+
pid = File.open(f) {|h| h.read}.to_i
|
43
|
+
rsl = ! Pid.running?(pid)
|
44
|
+
if rsl
|
45
|
+
puts "pid-file for killed process #{pid} found (#{f}), deleting."
|
46
|
+
begin; File.unlink(f); rescue ::Exception; end
|
47
|
+
end
|
48
|
+
rsl
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
41
52
|
return files
|
42
53
|
end
|
43
54
|
|
@@ -59,6 +70,16 @@ module Daemons
|
|
59
70
|
@multiple = multiple
|
60
71
|
@number = nil
|
61
72
|
@number = 0 if multiple
|
73
|
+
|
74
|
+
if multiple
|
75
|
+
while File.exist?(filename) and @number < 1024
|
76
|
+
@number += 1
|
77
|
+
end
|
78
|
+
|
79
|
+
if @number == 1024
|
80
|
+
raise RuntimeException('cannot run more than 1024 instances of the application')
|
81
|
+
end
|
82
|
+
end
|
62
83
|
end
|
63
84
|
|
64
85
|
def filename
|
@@ -70,16 +91,6 @@ module Daemons
|
|
70
91
|
end
|
71
92
|
|
72
93
|
def pid=(p)
|
73
|
-
if multiple
|
74
|
-
while File.exist?(filename) and @number < 1024
|
75
|
-
@number += 1
|
76
|
-
end
|
77
|
-
|
78
|
-
if @number == 1024
|
79
|
-
raise RuntimeException('cannot run more than 1024 instances of the application')
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
94
|
File.open(filename, 'w') {|f|
|
84
95
|
f.puts p #Process.pid
|
85
96
|
}
|
metadata
CHANGED
@@ -1,33 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: daemons
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0.
|
7
|
-
date: 2007-10-29 00:00:00 +01:00
|
8
|
-
summary: A toolkit to create and control daemons in different ways
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: th.uehlinger@gmx.ch
|
12
|
-
homepage: http://daemons.rubyforge.org
|
13
|
-
rubyforge_project: daemons
|
14
|
-
description: Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands. You can also call blocks as daemons and control them from the parent or just daemonize the current process. Besides this basic functionality, daemons offers many advanced features like exception backtracing and logging (in case your ruby script crashes) and monitoring and automatic restarting of your processes if they crash.
|
15
|
-
autorequire: daemons
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 1.0.10
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Thomas Uehlinger
|
8
|
+
autorequire: daemons
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-21 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands. You can also call blocks as daemons and control them from the parent or just daemonize the current process. Besides this basic functionality, daemons offers many advanced features like exception backtracing and logging (in case your ruby script crashes) and monitoring and automatic restarting of your processes if they crash.
|
17
|
+
email: th.uehlinger@gmx.ch
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
- Releases
|
25
|
+
- TODO
|
31
26
|
files:
|
32
27
|
- Rakefile
|
33
28
|
- Releases
|
@@ -46,11 +41,6 @@ files:
|
|
46
41
|
- lib/daemons/pidfile.rb
|
47
42
|
- lib/daemons/pidmem.rb
|
48
43
|
- lib/daemons.rb
|
49
|
-
- test/call_as_daemon.rb
|
50
|
-
- test/tc_main.rb
|
51
|
-
- test/test1.rb
|
52
|
-
- test/testapp.rb
|
53
|
-
- test/tmp
|
54
44
|
- examples/call
|
55
45
|
- examples/call/call.rb
|
56
46
|
- examples/call/call_monitor.rb
|
@@ -60,6 +50,7 @@ files:
|
|
60
50
|
- examples/run/ctrl_crash.rb
|
61
51
|
- examples/run/ctrl_exec.rb
|
62
52
|
- examples/run/ctrl_exit.rb
|
53
|
+
- examples/run/ctrl_keep_pid_files.rb
|
63
54
|
- examples/run/ctrl_monitor.rb
|
64
55
|
- examples/run/ctrl_multiple.rb
|
65
56
|
- examples/run/ctrl_normal.rb
|
@@ -67,24 +58,38 @@ files:
|
|
67
58
|
- examples/run/ctrl_optionparser.rb
|
68
59
|
- examples/run/ctrl_proc.rb
|
69
60
|
- examples/run/ctrl_proc.rb.output
|
61
|
+
- examples/run/ctrl_proc_multiple.rb
|
62
|
+
- examples/run/ctrl_proc_multiple.rb.output
|
70
63
|
- examples/run/ctrl_proc_simple.rb
|
71
64
|
- examples/run/myserver.rb
|
72
65
|
- examples/run/myserver_crashing.rb
|
73
66
|
- examples/run/myserver_crashing.rb.output
|
74
67
|
- examples/run/myserver_exiting.rb
|
75
|
-
|
76
|
-
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://daemons.rubyforge.org
|
70
|
+
post_install_message:
|
77
71
|
rdoc_options: []
|
78
72
|
|
79
|
-
|
80
|
-
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
version:
|
87
87
|
requirements: []
|
88
88
|
|
89
|
-
|
89
|
+
rubyforge_project: daemons
|
90
|
+
rubygems_version: 1.0.1
|
91
|
+
signing_key:
|
92
|
+
specification_version: 2
|
93
|
+
summary: A toolkit to create and control daemons in different ways
|
94
|
+
test_files: []
|
90
95
|
|
data/test/call_as_daemon.rb
DELETED
data/test/tc_main.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
|
3
|
-
#CURRENT_DIR = File.split(File.expand_path(__FILE__))[0]
|
4
|
-
|
5
|
-
#$LOAD_PATH << File.join(CURRENT_DIR, '../lib')
|
6
|
-
|
7
|
-
|
8
|
-
require 'pp'
|
9
|
-
|
10
|
-
require 'daemons'
|
11
|
-
|
12
|
-
|
13
|
-
class TestMain < Test::Unit::TestCase
|
14
|
-
|
15
|
-
def test_argv_parsing
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_run
|
19
|
-
#Daemons.run(File.join(CURRENT_DIR,'testapp.rb'))
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
|
data/test/test1.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
SCRIPT_DIR = File.split(File.expand_path(__FILE__))[0]
|
3
|
-
|
4
|
-
$LOAD_PATH << File.join(SCRIPT_DIR, '../lib')
|
5
|
-
|
6
|
-
|
7
|
-
require 'pp'
|
8
|
-
|
9
|
-
require 'daemons'
|
10
|
-
|
11
|
-
|
12
|
-
options = {
|
13
|
-
:dir_mode => :script,
|
14
|
-
:dir => 'tmp',
|
15
|
-
:multiple => true
|
16
|
-
}
|
17
|
-
|
18
|
-
Daemons.run(File.join(SCRIPT_DIR,'testapp.rb'), options)
|
19
|
-
|