daemons 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +1 -1
- data/Releases +5 -0
- data/examples/run/ctrl_normal.rb +0 -1
- data/examples/run/ctrl_proc_rand.rb +23 -0
- data/lib/daemons.rb +1 -1
- data/lib/daemons/application.rb +1 -0
- data/lib/daemons/daemonize.rb +7 -4
- metadata +30 -39
data/README
CHANGED
data/Releases
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
= Daemons Release History
|
2
2
|
|
3
|
+
== Release 1.1.9: August 10, 2012
|
4
|
+
|
5
|
+
* daemonize.rb: do srand in the forked child process both in daemonize and call_as_daemon
|
6
|
+
(thanks to Andrew Havens).
|
7
|
+
|
3
8
|
== Release 1.1.8: February 7, 2012
|
4
9
|
|
5
10
|
* rename to daemonization.rb to daemonize.rb (and Daemonization to Daemonize) to
|
data/examples/run/ctrl_normal.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
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
|
+
|
10
|
+
require 'daemons'
|
11
|
+
|
12
|
+
|
13
|
+
Daemons.run_proc('myscript') do
|
14
|
+
loop do
|
15
|
+
file = File.open('/tmp/myscript.log', 'a')
|
16
|
+
file.write(Random.rand) # breaks without seeding
|
17
|
+
# file.write(Random.new.rand) # works without seeding
|
18
|
+
# file.write(rand) # also works, but this is Kernel.rand() so its different
|
19
|
+
file.write("\n")
|
20
|
+
file.close()
|
21
|
+
sleep 2
|
22
|
+
end
|
23
|
+
end
|
data/lib/daemons.rb
CHANGED
data/lib/daemons/application.rb
CHANGED
data/lib/daemons/daemonize.rb
CHANGED
@@ -76,6 +76,9 @@ module Daemonize
|
|
76
76
|
|
77
77
|
redirect_io(logfile_name)
|
78
78
|
|
79
|
+
# Split rand streams between spawning and daemonized process
|
80
|
+
srand
|
81
|
+
|
79
82
|
block.call
|
80
83
|
|
81
84
|
exit
|
@@ -86,10 +89,7 @@ module Daemonize
|
|
86
89
|
|
87
90
|
# Transform the current process into a daemon
|
88
91
|
def daemonize(logfile_name = nil, app_name = nil)
|
89
|
-
#
|
90
|
-
srand
|
91
|
-
|
92
|
-
# Fork and exit from the parent
|
92
|
+
# Fork and exit from the parent
|
93
93
|
safefork and exit
|
94
94
|
|
95
95
|
# Detach from the controlling terminal
|
@@ -110,6 +110,9 @@ module Daemonize
|
|
110
110
|
|
111
111
|
redirect_io(logfile_name)
|
112
112
|
|
113
|
+
# Split rand streams between spawning and daemonized process
|
114
|
+
srand
|
115
|
+
|
113
116
|
return sess_id
|
114
117
|
end
|
115
118
|
module_function :daemonize
|
metadata
CHANGED
@@ -1,34 +1,31 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: daemons
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 1
|
8
|
-
- 8
|
9
|
-
version: 1.1.8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.9
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Thomas Uehlinger
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2012-02-07 00:00:00 +01:00
|
18
|
-
default_executable:
|
12
|
+
date: 2012-08-10 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
|
-
|
14
|
+
description: Daemons provides an easy way to wrap existing ruby scripts (for example
|
15
|
+
a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart
|
16
|
+
commands. You can also call blocks as daemons and control them from the parent
|
17
|
+
or just daemonize the current process. Besides this basic functionality, daemons
|
18
|
+
offers many advanced features like exception backtracing and logging (in case your
|
19
|
+
ruby script crashes) and monitoring and automatic restarting of your processes if
|
20
|
+
they crash.
|
22
21
|
email: th.uehlinger@gmx.ch
|
23
22
|
executables: []
|
24
|
-
|
25
23
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
24
|
+
extra_rdoc_files:
|
28
25
|
- README
|
29
26
|
- Releases
|
30
27
|
- TODO
|
31
|
-
files:
|
28
|
+
files:
|
32
29
|
- Rakefile
|
33
30
|
- Releases
|
34
31
|
- TODO
|
@@ -60,6 +57,7 @@ files:
|
|
60
57
|
- examples/run/ctrl_optionparser.rb
|
61
58
|
- examples/run/ctrl_proc.rb
|
62
59
|
- examples/run/ctrl_proc_multiple.rb
|
60
|
+
- examples/run/ctrl_proc_rand.rb
|
63
61
|
- examples/run/ctrl_proc_simple.rb
|
64
62
|
- examples/run/ctrl_slowstop.rb
|
65
63
|
- examples/run/myserver.rb
|
@@ -70,35 +68,28 @@ files:
|
|
70
68
|
- examples/call/call.rb
|
71
69
|
- examples/call/call_monitor.rb
|
72
70
|
- examples/daemonize/daemonize.rb
|
73
|
-
has_rdoc: true
|
74
71
|
homepage: http://daemons.rubyforge.org
|
75
72
|
licenses: []
|
76
|
-
|
77
73
|
post_install_message:
|
78
74
|
rdoc_options: []
|
79
|
-
|
80
|
-
require_paths:
|
75
|
+
require_paths:
|
81
76
|
- lib
|
82
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
94
|
-
- 0
|
95
|
-
version: "0"
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
96
89
|
requirements: []
|
97
|
-
|
98
90
|
rubyforge_project: daemons
|
99
|
-
rubygems_version: 1.
|
91
|
+
rubygems_version: 1.8.23
|
100
92
|
signing_key:
|
101
93
|
specification_version: 2
|
102
94
|
summary: A toolkit to create and control daemons in different ways
|
103
95
|
test_files: []
|
104
|
-
|