Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

Commit

Permalink
Улучшен pid мастер-процесса.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyralion committed Aug 29, 2012
1 parent ba6d8cd commit b8ef1ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 9 additions & 3 deletions README.md
Expand Up @@ -10,23 +10,29 @@ Ruby: 1.9.3

Rails: 3.0, 3.1, 3.2

### Tested with servers

WEBrik: 1.3.1
Thin: 1.4.1
Unicorn: 4.3.1

### Example

### Simple use
require 'imp'

Imp( "name-of-your-proccess", File.join("Path", "to", "log.file") ) do

# do some work
end

# or without logs
Imp( "name-of-your-proccess" ) do
# do some work
end

# ... later

Imp("name-of-your-proccess").start


### Lists of commands

# Show userful information about process
Expand Down
13 changes: 10 additions & 3 deletions lib/imp/trap.rb
Expand Up @@ -3,8 +3,6 @@ module Imp

module Trap

FILE_LOCK = "/tmp/imp_#{::Process.ppid}.lock".freeze

extend self

def catch
Expand Down Expand Up @@ -33,6 +31,13 @@ def catch

end # catch

def mpid

pid = ::Process.ppid
pid == 1 ? ::Process.pid : pid

end # mpid

private

def exit_process
Expand Down Expand Up @@ -63,4 +68,6 @@ def trap_signals

end # Trap

end # Imp
end # Imp

::Imp::Trap::FILE_LOCK = "/tmp/imp_#{::Imp::Trap.mpid}.lock".freeze

0 comments on commit b8ef1ee

Please sign in to comment.