daemonite 0.5.1 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +8 -5
- data/daemonite.gemspec +1 -1
- data/lib/daemonite.rb +14 -11
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1899e505246fe53e2c35fd6a9bacb56d88054fab42fba2f4b6bdf72a6382e8f
|
4
|
+
data.tar.gz: 6b5689d8dcf5394692aa69f0b6039aabda566a0a7a18cd3662e1eeed17d1b470
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 746048311f81405f042ff19cdf6b3a0ee6cd6739dd4afd14498b86a3cf54c25cf9efa6e8f5778944e4452f8912545494adf79e0aad6b345753d8e33e4c3f3d48
|
7
|
+
data.tar.gz: af685fb61f0466f1aacc5643a63107db35d7b3159f343e793d7a567ef55b7a4fb7e0f4158635c6ab497e3b874207243dca8e1f147f8b0a4f4a205db862a01293
|
data/Rakefile
CHANGED
@@ -1,19 +1,22 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rubygems/package_task'
|
3
|
-
require '
|
3
|
+
require 'fileutils'
|
4
4
|
|
5
5
|
spec = eval(File.read('daemonite.gemspec'))
|
6
6
|
Gem::PackageTask.new(spec) do |pkg|
|
7
7
|
pkg.need_zip = true
|
8
8
|
pkg.need_tar = true
|
9
|
-
|
10
|
-
|
9
|
+
FileUtils.mkdir 'pkg' rescue nil
|
10
|
+
FileUtils.rm_rf Dir.glob('pkg/*')
|
11
|
+
FileUtils.ln_sf "#{pkg.name}.gem", "pkg/#{spec.name}.gem"
|
11
12
|
end
|
12
13
|
|
14
|
+
task :default => :gem
|
15
|
+
|
13
16
|
task :push => :gem do |r|
|
14
|
-
`gem push pkg
|
17
|
+
`gem push pkg/#{spec.name}.gem`
|
15
18
|
end
|
16
19
|
|
17
20
|
task :install => :gem do |r|
|
18
|
-
`gem install pkg
|
21
|
+
`gem install pkg/#{spec.name}.gem`
|
19
22
|
end
|
data/daemonite.gemspec
CHANGED
data/lib/daemonite.rb
CHANGED
@@ -66,7 +66,7 @@ module Daemonism
|
|
66
66
|
opts.merge!(Psych::load_file(opts[:basepath] + '/' + f))
|
67
67
|
end
|
68
68
|
}
|
69
|
-
opt.on("--help", "-h", "This text.") { puts opt; exit
|
69
|
+
opt.on("--help", "-h", "This text.") { puts opt; ::Kernel::exit }
|
70
70
|
opt.separator(opt.summary_indent + "start|stop|restart|info".ljust(opt.summary_width+1) + "Do operation start, stop, restart or get information.")
|
71
71
|
opts[:runtime_cmds].each do |ro|
|
72
72
|
opt.separator(opt.summary_indent + ro[0].ljust(opt.summary_width+1) + ro[1])
|
@@ -74,9 +74,9 @@ module Daemonism
|
|
74
74
|
opt.parse!
|
75
75
|
}
|
76
76
|
|
77
|
-
unless (%w{start stop restart} + opts[:runtime_cmds].map{|ro| ro[0] }).include?(ARGV[0])
|
77
|
+
unless (%w{start stop restart info} + opts[:runtime_cmds].map{|ro| ro[0] }).include?(ARGV[0])
|
78
78
|
puts ARGV.options
|
79
|
-
exit
|
79
|
+
::Kernel::exit
|
80
80
|
end
|
81
81
|
opts[:cmdl_operation] = ARGV[0]
|
82
82
|
end
|
@@ -98,7 +98,7 @@ module Daemonism
|
|
98
98
|
unless @@daemonism_restart
|
99
99
|
if opts[:cmdl_operation] == "info" && status.call == false
|
100
100
|
puts "Server #{opts[:cmdl_info].nil? ? '' : '(' + opts[:cmdl_info].to_s + ') '}not running"
|
101
|
-
exit
|
101
|
+
::Kernel::exit
|
102
102
|
end
|
103
103
|
if opts[:cmdl_operation] == "info" && status.call == true
|
104
104
|
puts "Server #{opts[:cmdl_info].nil? ? '' : '(' + opts[:cmdl_info].to_s + ') '}running as #{pid}"
|
@@ -110,11 +110,11 @@ module Daemonism
|
|
110
110
|
puts "CPU Time: #{stats.last}"
|
111
111
|
rescue
|
112
112
|
end
|
113
|
-
exit
|
113
|
+
::Kernel::exit
|
114
114
|
end
|
115
115
|
if %w{start}.include?(opts[:cmdl_operation]) && status.call == true
|
116
116
|
puts "Server #{opts[:cmdl_info].nil? ? '' : '(' + opts[:cmdl_info].to_s + ') '}already started"
|
117
|
-
exit
|
117
|
+
::Kernel::exit
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
@@ -133,7 +133,7 @@ module Daemonism
|
|
133
133
|
sleep 0.3
|
134
134
|
end
|
135
135
|
end
|
136
|
-
exit
|
136
|
+
::Kernel::exit unless opts[:cmdl_operation] == "restart"
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -147,13 +147,13 @@ module Daemonism
|
|
147
147
|
@@daemonism_restart = true
|
148
148
|
|
149
149
|
retain = $stdout.dup
|
150
|
-
Process.daemon
|
150
|
+
Process.daemon unless opts[:verbose]
|
151
151
|
retain.puts "Server #{opts[:cmdl_info].nil? ? '' : '(' + opts[:cmdl_info].to_s + ') '}started as PID:#{Process.pid}"
|
152
152
|
File.write(opts[:basepath] + '/' + opts[:pidfile],Process.pid) # after daemon, so that we get the forked pid
|
153
153
|
Dir.chdir(opts[:basepath])
|
154
154
|
::Kernel::at_exit do
|
155
155
|
File.unlink(opts[:basepath] + '/' + opts[:pidfile])
|
156
|
-
@at_exit.call if @at_exit
|
156
|
+
@at_exit.call(opts) if @at_exit
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -174,6 +174,9 @@ module Daemonism
|
|
174
174
|
def on_startup(&blk)
|
175
175
|
on :startup, &blk
|
176
176
|
end
|
177
|
+
def use(blk)
|
178
|
+
instance_eval(&blk)
|
179
|
+
end
|
177
180
|
alias_method :at, :on
|
178
181
|
alias_method :at_exit, :on_exit
|
179
182
|
alias_method :at_startup, :on_startup
|
@@ -193,7 +196,7 @@ class Daemonite
|
|
193
196
|
|
194
197
|
def go!
|
195
198
|
begin
|
196
|
-
@at_startup.call if @at_startup
|
199
|
+
@at_startup.call(@opts) if @at_startup
|
197
200
|
@opts[:block].call(@opts)
|
198
201
|
rescue SystemExit, Interrupt
|
199
202
|
puts "Server stopped due to interrupt (PID:#{Process.pid})"
|
@@ -204,7 +207,7 @@ class Daemonite
|
|
204
207
|
|
205
208
|
def loop!
|
206
209
|
begin
|
207
|
-
@at_startup.call if @at_startup
|
210
|
+
@at_startup.call(@opts) if @at_startup
|
208
211
|
loop do
|
209
212
|
@opts[:block].call(@opts)
|
210
213
|
end unless @opts[:block].nil?
|
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.5.
|
4
|
+
version: 0.5.6
|
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:
|
11
|
+
date: 2020-07-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
|
@@ -44,8 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
|
-
|
48
|
-
rubygems_version: 2.7.6
|
47
|
+
rubygems_version: 3.1.2
|
49
48
|
signing_key:
|
50
49
|
specification_version: 4
|
51
50
|
summary: Daemonite - Process.daemon and argparse wrapper for loopies.
|