Module: ExtendedLockfile

Defined in:
lib/sup/util.rb

Instance Method Summary collapse

Instance Method Details

#dump_lock_id(lock_id = @lock_id) ⇒ Object



28
29
30
31
# File 'lib/sup/util.rb', line 28

def dump_lock_id lock_id = @lock_id
    "host: %s\npid: %s\nppid: %s\ntime: %s\nuser: %s\npname: %s\n" %
      lock_id.values_at('host','pid','ppid','time','user', 'pname')
end

#gen_lock_idObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/sup/util.rb', line 17

def gen_lock_id
  Hash[
       'host' => "#{ Socket.gethostname }",
       'pid' => "#{ Process.pid }",
       'ppid' => "#{ Process.ppid }",
       'time' => timestamp,
       'pname' => $0,
       'user' => ENV["USER"]
      ]
end

#lockinfo_on_diskObject



33
34
35
36
37
38
# File 'lib/sup/util.rb', line 33

def lockinfo_on_disk
  h = load_lock_id IO.read(path)
  h['mtime'] = File.mtime path
  h['path'] = path
  h
end

#touch_yourselfObject



40
# File 'lib/sup/util.rb', line 40

def touch_yourself; touch path end