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
65 66 67 |
# File 'lib/eye/local.rb', line 65 def client_timeout @client_timeout ||= default_client_timeout end |
.dir ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/eye/local.rb', line 7 def dir @dir ||= begin if root? if (_home = ENV['EYE_HOME']) && !_home.empty? File.(File.join(_home, '.eye')) else '/var/run/eye' end else File.(File.join(home, '.eye')) end end end |
.host ⇒ Object
73 74 75 76 77 78 |
# File 'lib/eye/local.rb', line 73 def host @host ||= begin require 'socket' Socket.gethostname end end |
.local_runner ⇒ Object
Returns the value of attribute local_runner.
99 100 101 |
# File 'lib/eye/local.rb', line 99 def local_runner @local_runner end |
Class Method Details
.cache_path ⇒ Object
57 58 59 |
# File 'lib/eye/local.rb', line 57 def cache_path path("processes#{ENV['EYE_V']}.cache") end |
.default_client_timeout ⇒ Object
61 62 63 |
# File 'lib/eye/local.rb', line 61 def default_client_timeout (ENV['EYE_CLIENT_TIMEOUT'] || 5).to_i end |
.ensure_eye_dir ⇒ Object
45 46 47 |
# File 'lib/eye/local.rb', line 45 def ensure_eye_dir FileUtils.mkdir_p(dir) unless ENV['EYE_SOCK'] && ENV['EYE_PID'] end |
.eyeconfig ⇒ Object
27 28 29 |
# File 'lib/eye/local.rb', line 27 def eyeconfig File.(File.join(home, '.eyeconfig')) end |
.eyefile ⇒ Object
80 81 82 |
# File 'lib/eye/local.rb', line 80 def eyefile @eyefile ||= find_eyefile(ENV['EYE_HOME'] || '.') end |
.find_eyefile(start_from_dir) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/eye/local.rb', line 84 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) previous = current current = File.('..', current) end end |
.global_eyeconfig ⇒ Object
23 24 25 |
# File 'lib/eye/local.rb', line 23 def global_eyeconfig '/etc/eye.conf' end |
.home ⇒ Object
35 36 37 38 39 |
# File 'lib/eye/local.rb', line 35 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
41 42 43 |
# File 'lib/eye/local.rb', line 41 def path(path) File.(path, dir) end |
.pid_path ⇒ Object
53 54 55 |
# File 'lib/eye/local.rb', line 53 def pid_path path(ENV['EYE_PID'] || "pid#{ENV['EYE_V']}") end |
.socket_path ⇒ Object
49 50 51 |
# File 'lib/eye/local.rb', line 49 def socket_path path(ENV['EYE_SOCK'] || "sock#{ENV['EYE_V']}") end |
.supported_setsid? ⇒ Boolean
69 70 71 |
# File 'lib/eye/local.rb', line 69 def supported_setsid? RUBY_VERSION >= '2.0' end |