Class: PidWatcher
- Inherits:
-
Object
- Object
- PidWatcher
- Defined in:
- lib/pid_watcher.rb,
lib/pid_watcher/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
- DEFAULT_TIMEOUT =
10 * 60
- DEFAULT_MESSAGE =
"Process %{pid} finished"
- TIMEOUT_MESSAGE =
"Timeout for process %{pid}"
- TITLE =
'Pid Watcher'
Instance Method Summary collapse
-
#initialize(pid, message = nil, timeout = nil) ⇒ PidWatcher
constructor
A new instance of PidWatcher.
- #watch ⇒ Object
Constructor Details
#initialize(pid, message = nil, timeout = nil) ⇒ PidWatcher
Returns a new instance of PidWatcher.
11 12 13 14 15 |
# File 'lib/pid_watcher.rb', line 11 def initialize(pid, = nil, timeout = nil) @pid = pid = || DEFAULT_MESSAGE @timeout = timeout || DEFAULT_TIMEOUT end |
Instance Method Details
#watch ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pid_watcher.rb', line 17 def watch Process.daemon(nil, true) Timeout::timeout(timeout) do while pid_exists? sleep(1) end finish_notify end rescue Timeout::Error timeout_notify end |