pidly 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 0.1.2 / 04/07/2011
2
+
3
+ * Callbacks#add_callback should be private
4
+ * added Pidly::Control#kill
5
+ * Cleaned up daemon output
6
+
1
7
  === 0.1.1 / 04/07/2011
2
8
 
3
9
  * Bug fixes
@@ -93,6 +93,24 @@ module Pidly
93
93
  def error(callback=nil, &block)
94
94
  add_callback(:error, (callback || block))
95
95
  end
96
+
97
+ #
98
+ # Kill
99
+ #
100
+ # Right before the kill instruction is sent the
101
+ # following callback will be invoked and executed.
102
+ #
103
+ # @param [Symbol] callback Method name
104
+ # @yield [] Code to be executed upon callback invocation
105
+ #
106
+ # @example
107
+ # kill :sent_kill_9_to_process
108
+ # # OR
109
+ # kill { puts "Forcefully killed process" }
110
+ #
111
+ def kill(callback=nil, &block)
112
+ add_callback(:kill, (callback || block))
113
+ end
96
114
 
97
115
  #
98
116
  # Add callback
@@ -116,6 +134,8 @@ module Pidly
116
134
  receiver.extend self
117
135
  end
118
136
 
137
+ private :add_callback
138
+
119
139
  end # modle Callbacks
120
140
 
121
141
  end # module Pidly
@@ -58,7 +58,7 @@ module Pidly
58
58
  end
59
59
 
60
60
  if options.has_key?(:pid_file)
61
- @pid_file = options.fetch(:pid_path)
61
+ @pid_file = options.fetch(:pid_file)
62
62
  else
63
63
  @pid_file = File.join(@path.to_s, 'pids', @name + '.pid')
64
64
  end
@@ -79,7 +79,7 @@ module Pidly
79
79
 
80
80
  @timeout = options.fetch(:timeout, 10)
81
81
 
82
- @verbosity = options.fetch(:verbose, false)
82
+ @verbosity = options.fetch(:verbose, true)
83
83
 
84
84
  @logger = options.fetch(:logger, true)
85
85
  end
@@ -129,7 +129,7 @@ module Pidly
129
129
 
130
130
  unless @allow_multiple
131
131
  if running?
132
- log(:error, "#{@name} is already running (PID #{@pid})")
132
+ log(:error, "\"#{@name}\" is already running (PID: #{@pid})")
133
133
  return
134
134
  end
135
135
  end
@@ -211,7 +211,7 @@ module Pidly
211
211
 
212
212
  else
213
213
  FileUtils.rm(@pid_file) if File.exists?(@pid_file)
214
- log(:info, "PID file not found.")
214
+ log(:info, "\"#{@name}\" PID file not found.")
215
215
  end
216
216
 
217
217
  rescue Errno::ENOENT
@@ -226,9 +226,9 @@ module Pidly
226
226
  #
227
227
  def status
228
228
  if running?
229
- log(:info, "#{@name} is running (PID #{@pid})")
229
+ log(:info, "\"#{@name}\" is running (PID: #{@pid})")
230
230
  else
231
- log(:info, "#{@name} is NOT running")
231
+ log(:info, "\"#{@name}\" is NOT running")
232
232
  end
233
233
  end
234
234
 
@@ -248,7 +248,8 @@ module Pidly
248
248
  #
249
249
  def kill(remove_pid_file=true)
250
250
  if running?
251
- log(:info, "Killing #{@name} (PID #{@pid})")
251
+ log(:info, "Killing \"#{@name}\" (PID: #{@pid})")
252
+ execute_callback(:kill)
252
253
  Process.kill 9, @pid
253
254
  end
254
255
 
@@ -1,4 +1,4 @@
1
1
  module Pidly
2
2
  # pidly version
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pidly
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dustin Willis Webber