dante 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/dante/runner.rb +26 -9
- data/lib/dante/version.rb +1 -1
- metadata +23 -3
data/README.md
CHANGED
@@ -129,7 +129,7 @@ You can also use dante programmatically to start, stop and restart arbitrary cod
|
|
129
129
|
|
130
130
|
```ruby
|
131
131
|
# daemon start
|
132
|
-
Dante::Runner.new('gitdocs').execute(:daemonize => true, :
|
132
|
+
Dante::Runner.new('gitdocs').execute(:daemonize => true, :pid_path => @pid, :log_path => @log_path) { something! }
|
133
133
|
# daemon stop
|
134
134
|
Dante::Runner.new('gitdocs').execute(:kill => true, :pid_path => @pid)
|
135
135
|
# daemon restart
|
data/lib/dante/runner.rb
CHANGED
@@ -2,6 +2,7 @@ require 'fileutils'
|
|
2
2
|
require 'optparse'
|
3
3
|
require 'yaml'
|
4
4
|
require 'erb'
|
5
|
+
require 'etc'
|
5
6
|
|
6
7
|
=begin
|
7
8
|
|
@@ -53,8 +54,20 @@ module Dante
|
|
53
54
|
self.stop
|
54
55
|
else # create process
|
55
56
|
self.stop if options.include?(:restart)
|
56
|
-
|
57
|
-
|
57
|
+
|
58
|
+
# If a username, uid, groupname, or gid is passed,
|
59
|
+
# drop privileges accordingly.
|
60
|
+
|
61
|
+
if options[:group]
|
62
|
+
gid = options[:group].is_a?(Integer) ? options[:group] : Etc.getgrnam(options[:group]).gid
|
63
|
+
Process::GID.change_privilege(gid)
|
64
|
+
end
|
65
|
+
|
66
|
+
if options[:user]
|
67
|
+
uid = options[:user].is_a?(Integer) ? options[:user] : Etc.getpwnam(options[:user]).uid
|
68
|
+
Process::UID.change_privilege(uid)
|
69
|
+
end
|
70
|
+
|
58
71
|
@startup_command = block if block_given?
|
59
72
|
options[:daemonize] ? daemonize : start
|
60
73
|
end
|
@@ -115,8 +128,12 @@ module Dante
|
|
115
128
|
end
|
116
129
|
|
117
130
|
def interrupt
|
118
|
-
|
119
|
-
|
131
|
+
# begin
|
132
|
+
raise Interrupt
|
133
|
+
sleep(1)
|
134
|
+
# rescue Interrupt
|
135
|
+
# log "Interrupt received; stopping #{@name}"
|
136
|
+
# end
|
120
137
|
end
|
121
138
|
|
122
139
|
# Returns true if process is not running
|
@@ -207,10 +224,10 @@ module Dante
|
|
207
224
|
def redirect_output!
|
208
225
|
if log_path = options[:log_path]
|
209
226
|
FileUtils.touch log_path
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
227
|
+
STDOUT.reopen(log_path, 'a')
|
228
|
+
STDERR.reopen STDOUT
|
229
|
+
File.chmod(0644, log_path)
|
230
|
+
STDOUT.sync = true
|
214
231
|
else # redirect to /dev/null
|
215
232
|
STDIN.reopen "/dev/null"
|
216
233
|
STDOUT.reopen "/dev/null", "a"
|
@@ -235,4 +252,4 @@ module Dante
|
|
235
252
|
end
|
236
253
|
|
237
254
|
end
|
238
|
-
end
|
255
|
+
end
|
data/lib/dante/version.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dante
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Nathan Esquenazi
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2012-
|
18
|
+
date: 2012-06-21 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rake
|
@@ -20,6 +25,9 @@ dependencies:
|
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
23
31
|
version: "0"
|
24
32
|
type: :development
|
25
33
|
version_requirements: *id001
|
@@ -31,6 +39,9 @@ dependencies:
|
|
31
39
|
requirements:
|
32
40
|
- - ">="
|
33
41
|
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
34
45
|
version: "0"
|
35
46
|
type: :development
|
36
47
|
version_requirements: *id002
|
@@ -42,6 +53,9 @@ dependencies:
|
|
42
53
|
requirements:
|
43
54
|
- - ">="
|
44
55
|
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
45
59
|
version: "0"
|
46
60
|
type: :development
|
47
61
|
version_requirements: *id003
|
@@ -80,17 +94,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
94
|
requirements:
|
81
95
|
- - ">="
|
82
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
83
100
|
version: "0"
|
84
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
102
|
none: false
|
86
103
|
requirements:
|
87
104
|
- - ">="
|
88
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
107
|
+
segments:
|
108
|
+
- 0
|
89
109
|
version: "0"
|
90
110
|
requirements: []
|
91
111
|
|
92
112
|
rubyforge_project: dante
|
93
|
-
rubygems_version: 1.8.
|
113
|
+
rubygems_version: 1.8.21
|
94
114
|
signing_key:
|
95
115
|
specification_version: 3
|
96
116
|
summary: Turn any process into a demon
|