Module: Eye::Local

Defined in:
lib/eye/local.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.local_runnerObject

Returns the value of attribute local_runner.



98
99
100
# File 'lib/eye/local.rb', line 98

def local_runner
  @local_runner
end

Class Method Details

.cache_pathObject



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

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

.client_timeoutObject



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

def client_timeout
  @client_timeout ||= 5
end

.client_timeout=(cl) ⇒ Object



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

def client_timeout=(cl)
  @client_timeout = cl
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

.dir=(d) ⇒ Object



15
16
17
# File 'lib/eye/local.rb', line 15

def dir=(d)
  @dir = d
end

.ensure_eye_dirObject



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

def ensure_eye_dir
  FileUtils.mkdir_p(dir)
end

.eyeconfigObject



19
20
21
22
23
24
25
# File 'lib/eye/local.rb', line 19

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

.eyefileObject



80
81
82
# File 'lib/eye/local.rb', line 80

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

.find_eyefile(start_from_dir) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/eye/local.rb', line 84

def find_eyefile(start_from_dir)
  fromenv = ENV['EYEFILE']
  return fromenv if fromenv && !fromenv.empty? && File.exist?(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

.homeObject



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

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

.hostObject



69
70
71
72
73
74
# File 'lib/eye/local.rb', line 69

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

.host=(hostname) ⇒ Object



76
77
78
# File 'lib/eye/local.rb', line 76

def host=(hostname)
  @host = hostname
end

.path(path) ⇒ Object



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

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

.pid_pathObject



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

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

.root?Boolean

Returns:

  • (Boolean)


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

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

.socket_pathObject



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

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

.supported_setsid?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/eye/local.rb', line 65

def supported_setsid?
  RUBY_VERSION >= '2.0'
end