module Invoker
Constants
- VERSION
Attributes
certificate[RW]
commander[RW]
config[RW]
daemonize[RW]
daemonize?[RW]
dns_cache[RW]
nocolors[RW]
nocolors?[RW]
private_key[RW]
tail_watchers[RW]
Public Class Methods
can_run_balancer?(throw_warning = true)
click to toggle source
# File lib/invoker.rb, line 71 def can_run_balancer?(throw_warning = true) return true if File.exist?(Invoker::Power::Config.config_file) if throw_warning Invoker::Logger.puts("Invoker has detected setup has not been run. Domain feature will not work without running setup command.".colorize(:red)) end false end
check_and_notify_with_terminal_notifier(message)
click to toggle source
# File lib/invoker.rb, line 113 def check_and_notify_with_terminal_notifier(message) command_path = `which terminal-notifier` if command_path && !command_path.empty? system("terminal-notifier -message '#{message}' -title Invoker") end end
close_socket(socket)
click to toggle source
# File lib/invoker.rb, line 61 def close_socket(socket) socket.close rescue StandardError => error Invoker::Logger.puts "Error removing socket #{error}" end
daemon()
click to toggle source
# File lib/invoker.rb, line 67 def daemon @daemon ||= Invoker::Daemon.new end
darwin?()
click to toggle source
# File lib/invoker.rb, line 42 def darwin? ruby_platform.downcase.include?("darwin") end
default_tld()
click to toggle source
# File lib/invoker.rb, line 147 def default_tld 'test' end
home()
click to toggle source
On some platforms ‘Dir.home` or `ENV` does not return home directory of user. this is especially true, after effective and real user id of process has been changed.
@return [String] home directory of the user
# File lib/invoker.rb, line 139 def home if File.writable?(Dir.home) Dir.home else Etc.getpwuid(Process.uid).dir end end
linux?()
click to toggle source
# File lib/invoker.rb, line 46 def linux? ruby_platform.downcase.include?("linux") end
load_invoker_config(file, port)
click to toggle source
# File lib/invoker.rb, line 54 def load_invoker_config(file, port) @config = Invoker::Parsers::Config.new(file, port) @dns_cache = Invoker::DNSCache.new(@invoker_config) @tail_watchers = Invoker::CLI::TailWatcher.new @commander = Invoker::Commander.new end
migrate_old_config(old_config, config_location)
click to toggle source
# File lib/invoker.rb, line 127 def migrate_old_config(old_config, config_location) new_config = File.join(config_location, 'config') File.open(new_config, 'w') do |file| file.write(old_config) end end
notify_user(message)
click to toggle source
# File lib/invoker.rb, line 105 def notify_user(message) if Invoker.darwin? run_without_bundler { check_and_notify_with_terminal_notifier(message) } elsif Invoker.linux? notify_with_libnotify(message) end end
notify_with_libnotify(message)
click to toggle source
# File lib/invoker.rb, line 120 def notify_with_libnotify(message) begin require "libnotify" Libnotify.show(body: message, summary: "Invoker", timeout: 2.5) rescue LoadError; end end
ruby_platform()
click to toggle source
# File lib/invoker.rb, line 50 def ruby_platform RUBY_PLATFORM end
run_without_bundler() { || ... }
click to toggle source
# File lib/invoker.rb, line 95 def run_without_bundler if defined?(Bundler) Bundler.with_unbundled_env do yield end else yield end end
setup_config_location()
click to toggle source
# File lib/invoker.rb, line 80 def setup_config_location config_dir = Invoker::Power::Config.config_dir return config_dir if Dir.exist?(config_dir) if File.exist?(config_dir) old_config = File.read(config_dir) FileUtils.rm_f(config_dir) end FileUtils.mkdir(config_dir) migrate_old_config(old_config, config_dir) if old_config config_dir end