daemonite 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/daemonite.gemspec +1 -1
- data/lib/daemonite.rb +30 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2aefaeee8ed856d896cb663cc2c2d8666f437e948e172d3d4f3bb8f8ac2bad5
|
4
|
+
data.tar.gz: 18face311c11441c3baa56eb74586bd13a2dc2fce37efd4475b4963121ae8b2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 481799bb690fec6d0090db1ff7e762ebf00ea65248c9b5a21311058b49b5661eb141c5f6dd930850c8e53d8f3809f668aedbe585702f337d8674061fef6fb009
|
7
|
+
data.tar.gz: 015b1b64ebe9e4f954275c8e526c9f5de27a1ee52d5c5b965d0284e7bff355a342db2d2dfda9af62070aff3cbec23444efb42ec3771cc8083f9547a36ac8ee57
|
data/daemonite.gemspec
CHANGED
data/lib/daemonite.rb
CHANGED
@@ -37,6 +37,9 @@ module Daemonism
|
|
37
37
|
}
|
38
38
|
|
39
39
|
def daemonism(opts={},&block)
|
40
|
+
@at_exit = nil
|
41
|
+
@at_start = nil
|
42
|
+
|
40
43
|
if File.exists?(opts[:basepath] + '/' + opts[:conffile])
|
41
44
|
opts.merge!(Psych::load_file(opts[:basepath] + '/' + opts[:conffile]))
|
42
45
|
end
|
@@ -70,12 +73,12 @@ module Daemonism
|
|
70
73
|
end
|
71
74
|
opt.parse!
|
72
75
|
}
|
73
|
-
|
76
|
+
|
77
|
+
unless (%w{start stop restart} + opts[:runtime_cmds].map{|ro| ro[0] }).include?(ARGV[0])
|
74
78
|
puts ARGV.options
|
75
|
-
exit
|
79
|
+
exit!
|
76
80
|
end
|
77
81
|
opts[:cmdl_operation] = ARGV[0]
|
78
|
-
@at_exit = nil
|
79
82
|
end
|
80
83
|
########################################################################################################################
|
81
84
|
opts[:runtime_proc].call(opts) unless opts[:runtime_proc].nil?
|
@@ -155,9 +158,25 @@ module Daemonism
|
|
155
158
|
end
|
156
159
|
end
|
157
160
|
|
158
|
-
def
|
159
|
-
|
161
|
+
def on(event,&blk)
|
162
|
+
case event
|
163
|
+
when :exit
|
164
|
+
@at_exit = blk
|
165
|
+
when :startup
|
166
|
+
@at_startup = blk
|
167
|
+
end
|
168
|
+
end
|
169
|
+
def exit; :exit; end
|
170
|
+
def startup; :startup; end
|
171
|
+
def on_exit(&blk)
|
172
|
+
on :exit, &blk
|
173
|
+
end
|
174
|
+
def on_startup(&blk)
|
175
|
+
on :startup, &blk
|
160
176
|
end
|
177
|
+
alias_method :at, :on
|
178
|
+
alias_method :at_exit, :on_exit
|
179
|
+
alias_method :at_startup, :on_startup
|
161
180
|
end
|
162
181
|
|
163
182
|
class Daemonite
|
@@ -174,7 +193,10 @@ class Daemonite
|
|
174
193
|
|
175
194
|
def go!
|
176
195
|
begin
|
196
|
+
@at_startup.call if @at_startup
|
177
197
|
@opts[:block].call(@opts)
|
198
|
+
rescue SystemExit, Interrupt
|
199
|
+
puts "Server stopped due to interrupt (PID:#{Process.pid})"
|
178
200
|
rescue => e
|
179
201
|
puts "Server stopped due to error (PID:#{Process.pid})"
|
180
202
|
end
|
@@ -182,9 +204,12 @@ class Daemonite
|
|
182
204
|
|
183
205
|
def loop!
|
184
206
|
begin
|
207
|
+
@at_startup.call if @at_startup
|
185
208
|
loop do
|
186
209
|
@opts[:block].call(@opts)
|
187
210
|
end unless @opts[:block].nil?
|
211
|
+
rescue SystemExit, Interrupt
|
212
|
+
puts "Server stopped due to interrupt (PID:#{Process.pid})"
|
188
213
|
rescue => e
|
189
214
|
puts "Server stopped due to error (PID:#{Process.pid})"
|
190
215
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daemonite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Daemonite - Process.daemon and argparse wrapper for loopies.
|
14
14
|
email: juergen.mangler@gmail.com
|