Module: Eye::Local
- Defined in:
- lib/eye/local.rb
Class Attribute Summary collapse
- .client_timeout ⇒ Object
- .dir ⇒ Object
- .host ⇒ Object
-
.local_runner ⇒ Object
Returns the value of attribute local_runner.
Class Method Summary collapse
- .cache_path ⇒ Object
- .default_client_timeout ⇒ Object
- .ensure_eye_dir ⇒ Object
- .eyeconfig ⇒ Object
- .eyefile ⇒ Object
- .find_eyefile(start_from_dir) ⇒ Object
- .global_eyeconfig ⇒ Object
- .home ⇒ Object
- .path(path) ⇒ Object
- .pid_path ⇒ Object
- .root? ⇒ Boolean
- .socket_path ⇒ Object
- .supported_setsid? ⇒ Boolean
Class Attribute Details
.client_timeout ⇒ Object
59 60 61 |
# File 'lib/eye/local.rb', line 59 def client_timeout @client_timeout ||= default_client_timeout end |
.dir ⇒ Object
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.(File.join(home, '.eye')) end end end |
.host ⇒ Object
67 68 69 70 71 72 |
# File 'lib/eye/local.rb', line 67 def host @host ||= begin require 'socket' Socket.gethostname end end |
.local_runner ⇒ Object
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_path ⇒ Object
51 52 53 |
# File 'lib/eye/local.rb', line 51 def cache_path path("processes#{ENV['EYE_V']}.cache") end |
.default_client_timeout ⇒ Object
55 56 57 |
# File 'lib/eye/local.rb', line 55 def default_client_timeout (ENV['EYE_CLIENT_TIMEOUT'] || 5).to_i end |
.ensure_eye_dir ⇒ Object
39 40 41 |
# File 'lib/eye/local.rb', line 39 def ensure_eye_dir FileUtils.mkdir_p(dir) end |
.eyeconfig ⇒ Object
21 22 23 |
# File 'lib/eye/local.rb', line 21 def eyeconfig File.(File.join(home, '.eyeconfig')) end |
.eyefile ⇒ Object
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.(start_from_dir) until !File.directory?(current) || current == previous filename = File.join(current, 'Eyefile') return filename if File.file?(filename) current, previous = File.('..', current), current end end |
.global_eyeconfig ⇒ Object
17 18 19 |
# File 'lib/eye/local.rb', line 17 def global_eyeconfig '/etc/eye.conf' end |
.home ⇒ Object
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.(path, dir) end |
.pid_path ⇒ Object
47 48 49 |
# File 'lib/eye/local.rb', line 47 def pid_path path(ENV['EYE_PID'] || "pid#{ENV['EYE_V']}") end |
.root? ⇒ Boolean
25 26 27 |
# File 'lib/eye/local.rb', line 25 def root? Process::UID.eid == 0 end |
.socket_path ⇒ Object
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
63 64 65 |
# File 'lib/eye/local.rb', line 63 def supported_setsid? RUBY_VERSION >= '2.0' end |