daemonite 0.5.2 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09519e4d9603836ae7592a8eec1dc4adb05d1b0e0f9ef272cabc8031465dd5d5'
4
- data.tar.gz: 36b52b06a8ef226e9a3a31da22c3ccaff5f952d0622b5a3774187bff6f45721b
3
+ metadata.gz: 62d8dd46ec738b5e6b246c86ceead1b03682b1579dd40a44048dbb316694bc5f
4
+ data.tar.gz: 3f25d52e80286edc9f6957b437edb53dcbe74deba57482237700358a2d801305
5
5
  SHA512:
6
- metadata.gz: 6d88c1f1283ae40234daaf2fd47af083325836cd8a852ed2284946b19dc115998289be44f2a642da2b69f0727c3efe20f98970f4063d626a5ff06c40f1d74fd8
7
- data.tar.gz: 478ff16c0a73a6fa855da7a47fe28065b6cd805cb7ee60189d7db6b8d233332137a6aef3e5c5a9eb59ff567eccb10e7b1d38dc6b6d54a0796bf1bf21a3480cbd
6
+ metadata.gz: 20c8c017f7f846fad18be36e40a2b5f32f2b285ed5fad2e83aa675756bcb0f0c55935e1ef04b15cda50b1283037e46d6903bc12519d21cbfbf0f1111c60b7ec3
7
+ data.tar.gz: 78a442b97feaa7d013fb4c46f8ded4264cffb199f0c5b9a55ad5470936e52a16bf8870678cf9d5361060b169ddb03cfea1ea8830b8541c351d578097c12b271a
data/Rakefile CHANGED
@@ -1,19 +1,22 @@
1
1
  require 'rake'
2
2
  require 'rubygems/package_task'
3
- require 'rake/testtask'
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
- `rm pkg/* -rf`
10
- `ln -sf #{pkg.name}.gem pkg/daemonite.gem`
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/daemonite.gem`
17
+ `gem push pkg/#{spec.name}.gem`
15
18
  end
16
19
 
17
20
  task :install => :gem do |r|
18
- `gem install pkg/daemonite.gem`
21
+ `gem install pkg/#{spec.name}.gem`
19
22
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "daemonite"
3
- s.version = "0.5.2"
3
+ s.version = "0.5.7"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Daemonite - Process.daemon and argparse wrapper for loopies."
@@ -33,7 +33,8 @@ module Daemonism
33
33
  :runtime_proc => nil,
34
34
  :cmdl_info => nil,
35
35
  :cmdl_parsing => true,
36
- :cmdl_operation => 'start'
36
+ :cmdl_operation => 'start',
37
+ :kill_amount => 1000
37
38
  }
38
39
 
39
40
  def daemonism(opts={},&block)
@@ -74,7 +75,7 @@ module Daemonism
74
75
  opt.parse!
75
76
  }
76
77
 
77
- unless (%w{start stop restart} + opts[:runtime_cmds].map{|ro| ro[0] }).include?(ARGV[0])
78
+ unless (%w{start stop restart info} + opts[:runtime_cmds].map{|ro| ro[0] }).include?(ARGV[0])
78
79
  puts ARGV.options
79
80
  ::Kernel::exit
80
81
  end
@@ -128,8 +129,14 @@ module Daemonism
128
129
  else
129
130
  puts "Server #{opts[:cmdl_info].nil? ? '' : '(' + opts[:cmdl_info].to_s + ') '}stopped"
130
131
  puts "Waiting while server goes down ..."
132
+ count = 0
131
133
  while status.call
132
- Process.kill "SIGTERM", pid
134
+ if count > opts[:kill_amount]
135
+ Process.kill "SIGKILL", pid
136
+ else
137
+ Process.kill "SIGTERM", pid
138
+ end
139
+ count += 1
133
140
  sleep 0.3
134
141
  end
135
142
  end
@@ -147,13 +154,13 @@ module Daemonism
147
154
  @@daemonism_restart = true
148
155
 
149
156
  retain = $stdout.dup
150
- Process.daemon(opts[:basepath]) unless opts[:verbose]
157
+ Process.daemon unless opts[:verbose]
151
158
  retain.puts "Server #{opts[:cmdl_info].nil? ? '' : '(' + opts[:cmdl_info].to_s + ') '}started as PID:#{Process.pid}"
152
159
  File.write(opts[:basepath] + '/' + opts[:pidfile],Process.pid) # after daemon, so that we get the forked pid
153
160
  Dir.chdir(opts[:basepath])
154
161
  ::Kernel::at_exit do
155
162
  File.unlink(opts[:basepath] + '/' + opts[:pidfile])
156
- @at_exit.call if @at_exit
163
+ @at_exit.call(opts) if @at_exit
157
164
  end
158
165
  end
159
166
  end
@@ -174,6 +181,9 @@ module Daemonism
174
181
  def on_startup(&blk)
175
182
  on :startup, &blk
176
183
  end
184
+ def use(blk)
185
+ instance_eval(&blk)
186
+ end
177
187
  alias_method :at, :on
178
188
  alias_method :at_exit, :on_exit
179
189
  alias_method :at_startup, :on_startup
@@ -193,7 +203,7 @@ class Daemonite
193
203
 
194
204
  def go!
195
205
  begin
196
- @at_startup.call if @at_startup
206
+ @at_startup.call(@opts) if @at_startup
197
207
  @opts[:block].call(@opts)
198
208
  rescue SystemExit, Interrupt
199
209
  puts "Server stopped due to interrupt (PID:#{Process.pid})"
@@ -204,7 +214,7 @@ class Daemonite
204
214
 
205
215
  def loop!
206
216
  begin
207
- @at_startup.call if @at_startup
217
+ @at_startup.call(@opts) if @at_startup
208
218
  loop do
209
219
  @opts[:block].call(@opts)
210
220
  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.2
4
+ version: 0.5.7
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-04-27 00:00:00.000000000 Z
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
- rubyforge_project:
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.