daemonite 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/daemonite.gemspec +1 -1
- data/lib/daemonite.rb +15 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 567ade4dfc4fe9ee3f3197da49396f24543ea63a36081b2eecd18df005d710c4
|
4
|
+
data.tar.gz: '082c6e0d745c63153107b4010165fdd233f73aadb39a4a3b5fd467f0f1aea109'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1260f526ba7d52c9bad716bbe624f609565b57b107857d67c4b08a220ccc3bc3caefd1590e3301082fea5bba92561940949e9a98f20e03197c42c372ffb1d679
|
7
|
+
data.tar.gz: ab1537ca34893bce3db176ec70189000ad23d8755912948857612e509ed2330c438f563e269de8f34555f62d39556bb3695b5d5baee8ff9337c529648b74b930
|
data/README.md
CHANGED
@@ -50,6 +50,32 @@ Daemonite.new(opts)
|
|
50
50
|
Also be aware that a json configuration file $PROGRAM_NAME.sub /\.rb$/, '.conf'
|
51
51
|
is automatically read, if it exists.
|
52
52
|
|
53
|
+
## Usage - Sinatra
|
54
|
+
|
55
|
+
Give PID file + daemon start, stop, restart, info functionality to sinatra. Stack overflow overflows with questions about it :-)
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
require 'sinatra/base'
|
59
|
+
require 'daemonite'
|
60
|
+
|
61
|
+
Daemonite.new do |opts|
|
62
|
+
on startup do
|
63
|
+
opts[:sin] = Sinatra.new do
|
64
|
+
set :port, 9327
|
65
|
+
Encoding.default_external = "UTF-8"
|
66
|
+
|
67
|
+
get '/' do
|
68
|
+
'Hello world!'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
run do
|
74
|
+
opts[:sin].run!
|
75
|
+
end
|
76
|
+
end.go!
|
77
|
+
```
|
78
|
+
|
53
79
|
## Usage - Alternative
|
54
80
|
|
55
81
|
```ruby
|
data/daemonite.gemspec
CHANGED
data/lib/daemonite.rb
CHANGED
@@ -39,7 +39,8 @@ module Daemonism
|
|
39
39
|
|
40
40
|
def daemonism(opts={},&block)
|
41
41
|
@at_exit = nil
|
42
|
-
@
|
42
|
+
@at_startup = nil
|
43
|
+
@at_setup = nil
|
43
44
|
|
44
45
|
if File.exists?(opts[:basepath] + '/' + opts[:conffile])
|
45
46
|
opts.merge!(Psych::load_file(opts[:basepath] + '/' + opts[:conffile]))
|
@@ -50,6 +51,7 @@ module Daemonism
|
|
50
51
|
opts[:block] = nil
|
51
52
|
instance_exec(opts,&block) if block_given?
|
52
53
|
|
54
|
+
|
53
55
|
########################################################################################################################
|
54
56
|
# parse arguments
|
55
57
|
########################################################################################################################
|
@@ -84,6 +86,11 @@ module Daemonism
|
|
84
86
|
########################################################################################################################
|
85
87
|
opts[:runtime_proc].call(opts) unless opts[:runtime_proc].nil?
|
86
88
|
|
89
|
+
########################################################################################################################
|
90
|
+
# call this if you want to change important things such as pidfile after parsing (but before any formal start)
|
91
|
+
########################################################################################################################
|
92
|
+
@at_setup.call(opts) if @at_setup
|
93
|
+
|
87
94
|
########################################################################################################################
|
88
95
|
# status and info
|
89
96
|
########################################################################################################################
|
@@ -176,22 +183,29 @@ module Daemonism
|
|
176
183
|
@at_exit = blk
|
177
184
|
when :startup
|
178
185
|
@at_startup = blk
|
186
|
+
when :setup
|
187
|
+
@at_setup = blk
|
179
188
|
end
|
180
189
|
end
|
181
190
|
def exit; :exit; end
|
182
191
|
def startup; :startup; end
|
192
|
+
def setup; :setup; end
|
183
193
|
def on_exit(&blk)
|
184
194
|
on :exit, &blk
|
185
195
|
end
|
186
196
|
def on_startup(&blk)
|
187
197
|
on :startup, &blk
|
188
198
|
end
|
199
|
+
def on_setup(&blk)
|
200
|
+
on :setup, &blk
|
201
|
+
end
|
189
202
|
def use(blk)
|
190
203
|
instance_eval(&blk)
|
191
204
|
end
|
192
205
|
alias_method :at, :on
|
193
206
|
alias_method :at_exit, :on_exit
|
194
207
|
alias_method :at_startup, :on_startup
|
208
|
+
alias_method :at_setup, :on_setup
|
195
209
|
end
|
196
210
|
|
197
211
|
class Daemonite
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-02 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
|
@@ -29,7 +29,7 @@ homepage: https://github.com/etm/daemonite.rb
|
|
29
29
|
licenses:
|
30
30
|
- LGPL-3.0
|
31
31
|
metadata: {}
|
32
|
-
post_install_message:
|
32
|
+
post_install_message:
|
33
33
|
rdoc_options: []
|
34
34
|
require_paths:
|
35
35
|
- lib
|
@@ -44,8 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
|
-
rubygems_version: 3.
|
48
|
-
signing_key:
|
47
|
+
rubygems_version: 3.3.26
|
48
|
+
signing_key:
|
49
49
|
specification_version: 4
|
50
50
|
summary: Daemonite - Process.daemon and argparse wrapper for loopies.
|
51
51
|
test_files: []
|