daemonite 0.5.9 → 0.7.0
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.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/daemonite.gemspec +1 -1
- data/lib/daemonite.rb +21 -3
- 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
@@ -34,12 +34,13 @@ module Daemonism
|
|
34
34
|
:cmdl_info => nil,
|
35
35
|
:cmdl_parsing => true,
|
36
36
|
:cmdl_operation => 'start',
|
37
|
-
:kill_amount =>
|
37
|
+
:kill_amount => 100
|
38
38
|
}
|
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
|
########################################################################################################################
|
@@ -135,7 +142,11 @@ module Daemonism
|
|
135
142
|
Process.kill "SIGKILL", pid
|
136
143
|
File.unlink(opts[:basepath] + '/' + opts[:pidfile])
|
137
144
|
else
|
138
|
-
|
145
|
+
if opts[:cmdl_operation] == 'stop'
|
146
|
+
Process.kill "SIGTERM", pid
|
147
|
+
else
|
148
|
+
Process.kill "SIGHUP", pid
|
149
|
+
end
|
139
150
|
end
|
140
151
|
count += 1
|
141
152
|
sleep 0.3
|
@@ -172,22 +183,29 @@ module Daemonism
|
|
172
183
|
@at_exit = blk
|
173
184
|
when :startup
|
174
185
|
@at_startup = blk
|
186
|
+
when :setup
|
187
|
+
@at_setup = blk
|
175
188
|
end
|
176
189
|
end
|
177
190
|
def exit; :exit; end
|
178
191
|
def startup; :startup; end
|
192
|
+
def setup; :setup; end
|
179
193
|
def on_exit(&blk)
|
180
194
|
on :exit, &blk
|
181
195
|
end
|
182
196
|
def on_startup(&blk)
|
183
197
|
on :startup, &blk
|
184
198
|
end
|
199
|
+
def on_setup(&blk)
|
200
|
+
on :setup, &blk
|
201
|
+
end
|
185
202
|
def use(blk)
|
186
203
|
instance_eval(&blk)
|
187
204
|
end
|
188
205
|
alias_method :at, :on
|
189
206
|
alias_method :at_exit, :on_exit
|
190
207
|
alias_method :at_startup, :on_startup
|
208
|
+
alias_method :at_setup, :on_setup
|
191
209
|
end
|
192
210
|
|
193
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: []
|