servitude 0.8.0 → 0.8.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8797f541827e4accebaddbbd1a40e78603225489
4
- data.tar.gz: 48b73b9c1630653ff2fcee45ee335d11e09cbebd
3
+ metadata.gz: 23ea7d595cc4e6e6f693d8d26fa47f6f7e4eea3b
4
+ data.tar.gz: b3f2bf6a2a41d2b8b597d05e428d7d6f9fad1175
5
5
  SHA512:
6
- metadata.gz: 6e4af9fe689fc799ab4be67dbb66138f1f797860b7c99be30066bb7deba1fc6e7490456104b94c23af7d466e03b0bd6d56c4a17a8a872f33df01bf61ffd1f7f7
7
- data.tar.gz: 6cad6cbcc17dfd3861fd65b630fe58cdf29c35a8630e56a8c3632246fd72293264a5ac709a836997c293551edd366d9dc256155e5a5fdae7196b20a5b383c93f
6
+ metadata.gz: 2ffe8ff8c1acad5c4109655d7a272c230358616789bb765a71ffdef6fb5677ca3d31cd57d16def6ade56d747df92ac35064e2d6023d3ae7b1b997d7abcc62893
7
+ data.tar.gz: 6a4f1bf29bdf089f79efac41a815796750a517f088aa5930ff8d49b2b1c22303f76b791b58edf74c8f70d00e774271f48aff48fe658bf56658622e1e0684c83a
@@ -54,6 +54,7 @@ module Servitude
54
54
 
55
55
  desc "status", "Check the status of the server daemon"
56
56
  pid_option
57
+ method_option :quiet, type: :boolean, aliases: '-q', desc: "Do not prompt to remove an old PID file", default: false
57
58
  def status
58
59
  result = Servitude::Daemon.new( options.merge( use_config: Servitude::USE_CONFIG )).status
59
60
  at_exit { exit result }
@@ -59,7 +59,7 @@ module Servitude
59
59
  true
60
60
  else
61
61
  puts "#{Servitude::APP_NAME} process does not exist"
62
- prompt_and_remove_pid_file if pid_file_exists?
62
+ prompt_and_remove_pid_file if pid_file_exists? && !options[:quiet]
63
63
  false
64
64
  end
65
65
  end
@@ -67,9 +67,9 @@ module Servitude
67
67
  protected
68
68
 
69
69
  def prompt_and_remove_pid_file
70
- puts "PID file still exists at '#{pid_path}', would you like to remove it (y/n)?"
70
+ $stdout.write "PID file still exists at '#{pid_path}'. Remove it [y/N]? "
71
71
  answer = $stdin.gets.strip
72
- if answer == 'y'
72
+ if answer =~ /^y(es)?$/i
73
73
  remove_pid
74
74
  puts "Removed PID file"
75
75
  end
@@ -89,16 +89,21 @@ module Servitude
89
89
  end
90
90
 
91
91
  def get_pid
92
- return nil unless File.file?( pid_path )
93
-
94
- pid = nil
95
-
96
- File.open( @pid_path, 'r' ) do |f|
97
- pid = f.readline.to_s.gsub( /[^0-9]/, '' )
98
- end
99
-
100
- pid.to_i
101
- rescue Errno::ENOENT
92
+ pid = begin
93
+ File.read( pid_path ).chomp
94
+ rescue Errno::ENOENT # No such file or directory
95
+ return nil
96
+ rescue Errno::EACCES # Permission denied
97
+ $stderr.puts "No permission to read #{pid_path}"
98
+ return nil
99
+ rescue => e
100
+ $stderr.puts "Unable to read #{pid_path}\n\t(#{e.class.name}) #{e.message}"
101
+ return nil
102
+ end
103
+
104
+ return pid.to_i if ( pid =~ /^[1-9][0-9]*$/ )
105
+
106
+ $stderr.puts "#{pid_path} does not contain a PID"
102
107
  nil
103
108
  end
104
109
 
@@ -147,6 +152,9 @@ module Servitude
147
152
  rescue Errno::EPERM
148
153
  $stderr.puts "No permission to query #{pid}!";
149
154
  false
155
+ rescue => e
156
+ $stderr.puts "Unable to query #{pid}\n\t(#{e.class.name}) #{e.message}"
157
+ false
150
158
  end
151
159
 
152
160
  def redirect_output!
@@ -1,3 +1,3 @@
1
1
  module Servitude
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servitude
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Harrelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  requirements: []
231
231
  rubyforge_project:
232
- rubygems_version: 2.2.1
232
+ rubygems_version: 2.4.4
233
233
  signing_key:
234
234
  specification_version: 4
235
235
  summary: A set of utilities to aid in building multithreaded Ruby servers utilizing