Module: Eye::Local

Defined in:
lib/eye/local.rb

Class Method Summary collapse

Class Method Details

.cache_pathObject



48
49
50
# File 'lib/eye/local.rb', line 48

def cache_path
  path("processes#{ENV['EYE_V']}.cache")
end

.client_timeoutObject



52
53
54
# File 'lib/eye/local.rb', line 52

def client_timeout
  5
end

.dirObject



6
7
8
9
10
11
12
# File 'lib/eye/local.rb', line 6

def dir
  if root?
    '/var/run/eye'
  else
    File.expand_path(File.join(home, '.eye'))
  end
end

.ensure_eye_dirObject



36
37
38
# File 'lib/eye/local.rb', line 36

def ensure_eye_dir
  FileUtils.mkdir_p( dir )
end

.eyeconfigObject



14
15
16
17
18
19
20
# File 'lib/eye/local.rb', line 14

def eyeconfig
  if root?
    '/etc/eye.conf'
  else
    File.expand_path(File.join(home, '.eyeconfig'))
  end
end

.homeObject



26
27
28
29
30
# File 'lib/eye/local.rb', line 26

def home
  h = ENV['EYE_HOME'] || ENV['HOME']
  raise "HOME undefined, should be HOME or EYE_HOME environment" unless h
  h
end

.hostObject



60
61
62
63
64
65
# File 'lib/eye/local.rb', line 60

def host
  @host ||= begin
    require 'socket'
    Socket.gethostname
  end
end

.host=(hostname) ⇒ Object



67
68
69
# File 'lib/eye/local.rb', line 67

def host=(hostname)
  @host = hostname
end

.path(path) ⇒ Object



32
33
34
# File 'lib/eye/local.rb', line 32

def path(path)
  File.join(dir, path)
end

.pid_pathObject



44
45
46
# File 'lib/eye/local.rb', line 44

def pid_path
  path(ENV['EYE_PID'] || "pid#{ENV['EYE_V']}")
end

.root?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/eye/local.rb', line 22

def root?
  Process::UID.eid == 0
end

.socket_pathObject



40
41
42
# File 'lib/eye/local.rb', line 40

def socket_path
  path(ENV['EYE_SOCK'] || "sock#{ENV['EYE_V']}")
end

.supported_setsid?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/eye/local.rb', line 56

def supported_setsid?
  RUBY_VERSION >= '2.0'
end