module Gears::Services

Installs Gears service packages

Public Class Methods

create_paths() click to toggle source
# File lib/robot_sweatshop/gears/services.rb, line 46
def self.create_paths
  config = Gears::Metadata.sweatshop_config
  FileUtils.mkpath "#{config[:logfile_path]}/gears"
  FileUtils.mkpath "#{config[:pidfile_path]}/gears"
end
dynamically_load_eye_from(services_path) click to toggle source
# File lib/robot_sweatshop/gears/services.rb, line 34
def self.dynamically_load_eye_from(services_path)
  context = {
    config: Gears::Metadata.sweatshop_config,
    services: installed_in(services_path),
    services_path: services_path,
    first_port: first_port
  }
  input = File.read "#{__dir__}/templates/sweatshop_gears.eye.eruby"
  eruby = Erubis::Eruby.new input
  write_and_load eruby.result(context)
end
expose(from_path:) click to toggle source
# File lib/robot_sweatshop/gears/services.rb, line 8
def self.expose(from_path:)
  services_path = File.expand_path "#{from_path}/.."
  dynamically_load_eye_from services_path
  service = File.basename from_path
  Announce.success "Loaded #{service} into Eye"
end
eye_file() click to toggle source
# File lib/robot_sweatshop/gears/services.rb, line 26
def self.eye_file
  '/tmp/.sweatshop_gears.eye'
end
first_port() click to toggle source
# File lib/robot_sweatshop/gears/services.rb, line 30
def self.first_port
  34871
end
installed_in(path) click to toggle source
# File lib/robot_sweatshop/gears/services.rb, line 21
def self.installed_in(path)
  services = Dir.glob("#{path}/*").select { |path| File.directory? path }
  services.map { |path| File.basename path }
end
write_and_load(eye_config) click to toggle source
# File lib/robot_sweatshop/gears/services.rb, line 15
def self.write_and_load(eye_config)
  File.write eye_file, eye_config
  puts `eye load #{eye_file}`
  puts `eye stop sweatshop_gears`
end