daemonite 0.5.3 → 0.5.8

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: 3b38490b5b0512257356f5a795ae21892db6f3908bc2dd574e8c892b6ceeb49e
4
- data.tar.gz: c2303181b47f5e2af0377c5237b0b802d12359767c77d28f115729d8b28cf344
3
+ metadata.gz: e7171fd2b57ae339e62582e061674b842acf8f9a27ab5af76911db78f8508888
4
+ data.tar.gz: a94b9770dfe0fc681a3f2d3949d1251cee757dafa45c6a7a4e78e54545a4f7e8
5
5
  SHA512:
6
- metadata.gz: c343e7e31472ee931a009fc0c15da8a48ebbd6285c30ef190cc5fa330712781a0bb652033ee043d6f0122fb531fea27d0be1571c6364d83bb69170120697f351
7
- data.tar.gz: bf82bbea8ff912c127d8b77e9b2ebf4435b330dcb66ca001df9816864f0f8addd148e18bd245908b8536eec6314be271429295cc80480ed4fe620ed544f088ed
6
+ metadata.gz: f2795a00b76410582129a9dabdc9340ca01dd120d12491d550bbbc16fa1300f1d9404eb3bd07b8b6a6bf40ad94c08c06f1f2dbddea2f6da6ae8473e4feef0552
7
+ data.tar.gz: 6c523afdded907f6d346908b95a7d6fed4218e1dba5ce45d96bf631afa1165bc52be9cbd2517bdbddbff18ad996607b6fb53ea4d827aef230760340139801185
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.3"
3
+ s.version = "0.5.8"
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)
@@ -128,8 +129,16 @@ 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
+ File.unlink(opts[:basepath] + '/' + opts[:pidfile])
137
+ @at_exit.call(opts) if @at_exit
138
+ else
139
+ Process.kill "SIGTERM", pid
140
+ end
141
+ count += 1
133
142
  sleep 0.3
134
143
  end
135
144
  end
@@ -147,13 +156,13 @@ module Daemonism
147
156
  @@daemonism_restart = true
148
157
 
149
158
  retain = $stdout.dup
150
- Process.daemon(opts[:basepath]) unless opts[:verbose]
159
+ Process.daemon unless opts[:verbose]
151
160
  retain.puts "Server #{opts[:cmdl_info].nil? ? '' : '(' + opts[:cmdl_info].to_s + ') '}started as PID:#{Process.pid}"
152
161
  File.write(opts[:basepath] + '/' + opts[:pidfile],Process.pid) # after daemon, so that we get the forked pid
153
162
  Dir.chdir(opts[:basepath])
154
163
  ::Kernel::at_exit do
155
164
  File.unlink(opts[:basepath] + '/' + opts[:pidfile])
156
- @at_exit.call if @at_exit
165
+ @at_exit.call(opts) if @at_exit
157
166
  end
158
167
  end
159
168
  end
@@ -174,6 +183,9 @@ module Daemonism
174
183
  def on_startup(&blk)
175
184
  on :startup, &blk
176
185
  end
186
+ def use(blk)
187
+ instance_eval(&blk)
188
+ end
177
189
  alias_method :at, :on
178
190
  alias_method :at_exit, :on_exit
179
191
  alias_method :at_startup, :on_startup
@@ -193,7 +205,7 @@ class Daemonite
193
205
 
194
206
  def go!
195
207
  begin
196
- @at_startup.call if @at_startup
208
+ @at_startup.call(@opts) if @at_startup
197
209
  @opts[:block].call(@opts)
198
210
  rescue SystemExit, Interrupt
199
211
  puts "Server stopped due to interrupt (PID:#{Process.pid})"
@@ -204,7 +216,7 @@ class Daemonite
204
216
 
205
217
  def loop!
206
218
  begin
207
- @at_startup.call if @at_startup
219
+ @at_startup.call(@opts) if @at_startup
208
220
  loop do
209
221
  @opts[:block].call(@opts)
210
222
  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.3
4
+ version: 0.5.8
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.