daemons 1.2.4 → 1.2.5

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
  SHA1:
3
- metadata.gz: 860b58ef469300cda2269a45f189796af8f36bcb
4
- data.tar.gz: 29894094754c8013a9901f918f9e9ca2d700258f
3
+ metadata.gz: 87cdbadcf8ce1d77533557b7d0f359dc5a750fe5
4
+ data.tar.gz: 00ca7e0da7abb35af6ca5ed389c9903f5212ee4c
5
5
  SHA512:
6
- metadata.gz: cd7e03dbc97d7dcaa21b582b868cea9b5610e52b975737b8c8309ce71f803647d3a87444e04a79b63feb2da895b0ee5ab8624985540c4a5dfba0be916f23d55a
7
- data.tar.gz: c42a97021220ffbbe114349c8fe2ebeff0894b265cd4c2a960cf9efbdce5b0bcf873d92dd393b54fdde336b4d53c8ea4c53d827f567d0313829fd0f4f23c7cdb
6
+ metadata.gz: '092c646fb307604e652b88e00444b55b1cc332add1657e0351fee23093e86caec7413f507e599538b3cfcf28e28de5ec16003e225505fb0661cc837af622a57b'
7
+ data.tar.gz: 87e93b5cf8209905b2d9aa0404461f35ef06ab7e6c653195402112fea17583cd8e2c135429d354a8899da86bf691d4c70c127418f8029d05cd6747b89c0988f7
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005-2016 Thomas Uehlinger, 2014-2016 Aaron Stone
1
+ Copyright (c) 2005-2017 Thomas Uehlinger, 2014-2016 Aaron Stone
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Ruby Daemons
2
2
  ============
3
- [![Code Climate](https://codeclimate.com/github/acuppy/daemons/badges/gpa.svg)](https://codeclimate.com/github/acuppy/daemons)[![Test Coverage](https://circleci.com/gh/acuppy/daemons.svg?style=shield&circle-token=a4f96fd41f7682661d6543e30207427ac8870c0d)](https://circleci.com/gh/acuppy/daemons)
3
+ [![Build Status](https://travis-ci.org/thuehlinger/daemons.svg?branch=master)](https://travis-ci.org/thuehlinger/daemons)[![Code Climate](https://codeclimate.com/github/acuppy/daemons/badges/gpa.svg)](https://codeclimate.com/github/acuppy/daemons)[![Test Coverage](https://circleci.com/gh/acuppy/daemons.svg?style=shield&circle-token=a4f96fd41f7682661d6543e30207427ac8870c0d)](https://circleci.com/gh/acuppy/daemons)
4
4
 
5
5
  Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server)
6
6
  to be _run as a daemon_ and to be _controlled by simple start/stop/restart commands_.
@@ -204,4 +204,4 @@ Daemons.run('myserver.rb', { show_status_callback: :custom_show_status })
204
204
  Author
205
205
  ------
206
206
 
207
- Written 2005-2016 by Thomas Uehlinger, 2014-2016 by Aaron Stone.
207
+ Written 2005-2017 by Thomas Uehlinger, 2014-2016 by Aaron Stone.
data/Releases CHANGED
@@ -1,5 +1,10 @@
1
1
  = Daemons Release History
2
2
 
3
+ == Release 1.2.5: October 22, 2017
4
+
5
+ * In Application#stop, call zap, not cleanup on the pidfile (thanks to wevanscfi)
6
+ * Use File.expand_path on and output and log files (thanks to Dave Harris)
7
+
3
8
  == Release 1.2.4: August 1, 2016
4
9
 
5
10
  * add :shush option
@@ -238,23 +238,26 @@ module Daemons
238
238
  # end
239
239
  #
240
240
  def call(options = {}, &block)
241
- unless block_given?
242
- fail 'Daemons.call: no block given'
243
- end
241
+ new_app = Daemons.new(options, &block)
242
+ new_app.start
243
+ new_app
244
+ end
245
+ module_function :call
244
246
 
245
- options[:proc] = block
246
- options[:mode] = :proc
247
+ # Create a new Daemon application, like <tt>Daemons.call</tt>, but will not start it automatically
248
+ def new(options = {}, &block)
249
+ fail 'Daemons.call: no block given' unless block_given?
247
250
 
248
251
  options[:app_name] ||= 'proc'
252
+ options[:proc] = Proc.new
253
+ options[:mode] = :proc
254
+ options[:dir_mode] = :normal
249
255
 
250
256
  @group ||= ApplicationGroup.new(options[:app_name], options)
251
257
 
252
- new_app = @group.new_application(options)
253
- new_app.start
254
-
255
- new_app
258
+ @group.new_application(options)
256
259
  end
257
- module_function :call
260
+ module_function :new
258
261
 
259
262
  # Daemonize the currently runnig process, i.e. the calling process will become a daemon.
260
263
  #
@@ -28,6 +28,10 @@ module Daemons
28
28
  @options = group.options.dup
29
29
  @options.update(add_options)
30
30
 
31
+ ['dir', 'log_dir', 'logfilename', 'output_logfilename'].each do |k|
32
+ @options[k] = File.expand_path(@options[k]) if @options.key?(k)
33
+ end
34
+
31
35
  @dir_mode = @dir = @script = nil
32
36
 
33
37
  @force_kill_waittime = @options[:force_kill_waittime] || 20
@@ -416,7 +420,7 @@ module Daemons
416
420
  unless Pid.running?(pid)
417
421
  # We try to remove the pid-files by ourselves, in case the application
418
422
  # didn't clean it up.
419
- begin; @pid.cleanup; rescue ::Exception; end
423
+ zap!
420
424
 
421
425
  @report.stopped_process(group.app_name, pid)
422
426
  $stdout.flush
@@ -23,19 +23,22 @@ module Daemons
23
23
  @app_name = app_name
24
24
  @options = options
25
25
 
26
- if options[:script]
27
- @script = File.expand_path(options[:script])
26
+ if @options[:script]
27
+ @script = File.expand_path(@options[:script])
28
28
  end
29
29
 
30
30
  @monitor = nil
31
31
 
32
- @multiple = options[:multiple] || false
32
+ @multiple = @options[:multiple] || false
33
33
 
34
- @dir_mode = options[:dir_mode] || :script
35
- @dir = options[:dir] || ''
34
+ @dir_mode = @options[:dir_mode] || :script
35
+ ['dir'].each do |k|
36
+ @options[k] = File.expand_path(@options[k]) if @options.key?(k)
37
+ end
38
+ @dir = @options[:dir] || ''
36
39
 
37
- @keep_pid_files = options[:keep_pid_files] || false
38
- @no_pidfiles = options[:no_pidfiles] || false
40
+ @keep_pid_files = @options[:keep_pid_files] || false
41
+ @no_pidfiles = @options[:no_pidfiles] || false
39
42
 
40
43
  @applications = []
41
44
  end
@@ -61,7 +61,7 @@ module Daemons
61
61
  @group.stop_all(@options[:no_wait])
62
62
  when 'restart'
63
63
  unless @group.applications.empty?
64
- @group.stop_all
64
+ @group.stop_all(@options[:no_wait])
65
65
  sleep(1)
66
66
  @group.start_all
67
67
  else
@@ -107,7 +107,7 @@ module Daemons
107
107
  end
108
108
  rescue ::Exception => e
109
109
  $stderr.puts "exception while trying to stop monitor process #{pid}: #{e}"
110
- $stderr.puts 'deleting pid-file.'
110
+ $stderr.puts "deleting pid-file."
111
111
  end
112
112
 
113
113
  # We try to remove the pid-files by ourselves, in case the monitor
@@ -100,9 +100,9 @@ module Daemons
100
100
  end
101
101
 
102
102
  def zap
103
- File.delete(filename)
103
+ File.delete(filename) if exist?
104
104
  end
105
-
105
+
106
106
  def pid
107
107
  begin
108
108
  File.open(filename) do |f|
@@ -1,3 +1,3 @@
1
1
  module Daemons
2
- VERSION = '1.2.4'
2
+ VERSION = '1.2.5'
3
3
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Uehlinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-01 00:00:00.000000000 Z
11
+ date: 2017-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry-byebug
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 3.0.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 3.0.0
69
69
  description: |2
70
70
  Daemons provides an easy way to wrap existing ruby scripts (for example a
71
71
  self-written server) to be run as a daemon and to be controlled by simple
@@ -137,17 +137,17 @@ require_paths:
137
137
  - lib
138
138
  required_ruby_version: !ruby/object:Gem::Requirement
139
139
  requirements:
140
- - - '>='
140
+ - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - '>='
145
+ - - ">="
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
149
  rubyforge_project:
150
- rubygems_version: 2.4.6
150
+ rubygems_version: 2.5.2
151
151
  signing_key:
152
152
  specification_version: 4
153
153
  summary: A toolkit to create and control daemons in different ways