Module: Eye::Local

Defined in:
lib/eye/local.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.client_timeoutObject



59
60
61
# File 'lib/eye/local.rb', line 59

def client_timeout
  @client_timeout ||= default_client_timeout
end

.dirObject



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

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

.hostObject



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

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

.local_runnerObject

Returns the value of attribute local_runner.



92
93
94
# File 'lib/eye/local.rb', line 92

def local_runner
  @local_runner
end

Class Method Details

.cache_pathObject



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

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

.default_client_timeoutObject



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

def default_client_timeout
  (ENV['EYE_CLIENT_TIMEOUT'] || 5).to_i
end

.ensure_eye_dirObject



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

def ensure_eye_dir
  FileUtils.mkdir_p(dir)
end

.eyeconfigObject



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

def eyeconfig
  File.expand_path(File.join(home, '.eyeconfig'))
end

.eyefileObject



74
75
76
# File 'lib/eye/local.rb', line 74

def eyefile
  @eyefile ||= find_eyefile('.')
end

.find_eyefile(start_from_dir) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/eye/local.rb', line 78

def find_eyefile(start_from_dir)
  fromenv = ENV['EYE_FILE']
  return fromenv if fromenv && !fromenv.empty? && File.file?(fromenv)

  previous = nil
  current  = File.expand_path(start_from_dir)

  until !File.directory?(current) || current == previous
    filename = File.join(current, 'Eyefile')
    return filename if File.file?(filename)
    current, previous = File.expand_path('..', current), current
  end
end

.global_eyeconfigObject



17
18
19
# File 'lib/eye/local.rb', line 17

def global_eyeconfig
  '/etc/eye.conf'
end

.homeObject



29
30
31
32
33
# File 'lib/eye/local.rb', line 29

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

.path(path) ⇒ Object



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

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

.pid_pathObject



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

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

.root?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/eye/local.rb', line 25

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

.socket_pathObject



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

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

.supported_setsid?Boolean

Returns:

  • (Boolean)


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

def supported_setsid?
  RUBY_VERSION >= '2.0'
end