Module: Invoker
- Defined in:
- lib/invoker.rb,
lib/invoker/cli.rb,
lib/invoker/ipc.rb,
lib/invoker/daemon.rb,
lib/invoker/errors.rb,
lib/invoker/logger.rb,
lib/invoker/reactor.rb,
lib/invoker/version.rb,
lib/invoker/cli/tail.rb,
lib/invoker/commander.rb,
lib/invoker/dns_cache.rb,
lib/invoker/power/dns.rb,
lib/invoker/cli/pinger.rb,
lib/invoker/ipc/server.rb,
lib/invoker/ipc/message.rb,
lib/invoker/power/setup.rb,
lib/invoker/cli/question.rb,
lib/invoker/power/config.rb,
lib/invoker/event/manager.rb,
lib/invoker/power/powerup.rb,
lib/invoker/command_worker.rb,
lib/invoker/parsers/config.rb,
lib/invoker/power/balancer.rb,
lib/invoker/reactor/reader.rb,
lib/invoker/ipc/add_command.rb,
lib/invoker/ipc/unix_client.rb,
lib/invoker/process_manager.rb,
lib/invoker/process_printer.rb,
lib/invoker/cli/tail_watcher.rb,
lib/invoker/ipc/base_command.rb,
lib/invoker/ipc/list_command.rb,
lib/invoker/ipc/ping_command.rb,
lib/invoker/ipc/tail_command.rb,
lib/invoker/parsers/procfile.rb,
lib/invoker/power/http_parser.rb,
lib/invoker/power/port_finder.rb,
lib/invoker/ipc/client_handler.rb,
lib/invoker/ipc/reload_command.rb,
lib/invoker/ipc/remove_command.rb,
lib/invoker/power/url_rewriter.rb,
lib/invoker/power/http_response.rb,
lib/invoker/ipc/add_http_command.rb,
lib/invoker/ipc/dns_check_command.rb,
lib/invoker/power/setup/osx_setup.rb,
lib/invoker/power/setup/distro/arch.rb,
lib/invoker/power/setup/distro/base.rb,
lib/invoker/power/setup/linux_setup.rb,
lib/invoker/ipc/message/list_response.rb,
lib/invoker/ipc/message/tail_response.rb,
lib/invoker/power/setup/distro/debian.rb,
lib/invoker/power/setup/distro/redhat.rb,
lib/invoker/power/setup/distro/ubuntu.rb,
lib/invoker/power/setup/distro/opensuse.rb
Defined Under Namespace
Modules: Errors, Event, IPC, Parsers, Power
Classes: CLI, CommandWorker, Commander, DNSCache, Daemon, Logger, ProcessManager, ProcessPrinter, Reactor, Version
Constant Summary
collapse
- VERSION =
"2.0.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.certificate ⇒ Object
Returns the value of attribute certificate.
37
38
39
|
# File 'lib/invoker.rb', line 37
def certificate
@certificate
end
|
.commander ⇒ Object
Returns the value of attribute commander.
36
37
38
|
# File 'lib/invoker.rb', line 36
def commander
@commander
end
|
.config ⇒ Object
Returns the value of attribute config.
36
37
38
|
# File 'lib/invoker.rb', line 36
def config
@config
end
|
.daemonize ⇒ Object
Also known as:
daemonize?
Returns the value of attribute daemonize.
37
38
39
|
# File 'lib/invoker.rb', line 37
def daemonize
@daemonize
end
|
.dns_cache ⇒ Object
Returns the value of attribute dns_cache.
37
38
39
|
# File 'lib/invoker.rb', line 37
def dns_cache
@dns_cache
end
|
.nocolors ⇒ Object
Also known as:
nocolors?
Returns the value of attribute nocolors.
37
38
39
|
# File 'lib/invoker.rb', line 37
def nocolors
@nocolors
end
|
.private_key ⇒ Object
Returns the value of attribute private_key.
37
38
39
|
# File 'lib/invoker.rb', line 37
def private_key
@private_key
end
|
.tail_watchers ⇒ Object
Returns the value of attribute tail_watchers.
36
37
38
|
# File 'lib/invoker.rb', line 36
def tail_watchers
@tail_watchers
end
|
Class Method Details
.can_run_balancer?(throw_warning = true) ⇒ Boolean
71
72
73
74
75
76
77
78
|
# 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) ⇒ Object
113
114
115
116
117
118
|
# 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) ⇒ Object
61
62
63
64
65
|
# File 'lib/invoker.rb', line 61
def close_socket(socket)
socket.close
rescue StandardError => error
Invoker::Logger.puts "Error removing socket #{error}"
end
|
.daemon ⇒ Object
67
68
69
|
# File 'lib/invoker.rb', line 67
def daemon
@daemon ||= Invoker::Daemon.new
end
|
.darwin? ⇒ Boolean
42
43
44
|
# File 'lib/invoker.rb', line 42
def darwin?
ruby_platform.downcase.include?("darwin")
end
|
.default_tld ⇒ Object
147
148
149
|
# File 'lib/invoker.rb', line 147
def default_tld
'test'
end
|
.home ⇒ String
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.
139
140
141
142
143
144
145
|
# File 'lib/invoker.rb', line 139
def home
if File.writable?(Dir.home)
Dir.home
else
Etc.getpwuid(Process.uid).dir
end
end
|
.linux? ⇒ Boolean
46
47
48
|
# File 'lib/invoker.rb', line 46
def linux?
ruby_platform.downcase.include?("linux")
end
|
.load_invoker_config(file, port) ⇒ Object
.migrate_old_config(old_config, config_location) ⇒ Object
127
128
129
130
131
132
|
# 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) ⇒ Object
105
106
107
108
109
110
111
|
# 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) ⇒ Object
120
121
122
123
124
125
|
# 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
|
50
51
52
|
# File 'lib/invoker.rb', line 50
def ruby_platform
RUBY_PLATFORM
end
|
.run_without_bundler ⇒ Object
95
96
97
98
99
100
101
102
103
|
# 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 ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# 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
|