7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/legion/cli/start.rb', line 7
def run(options)
if options[:lite]
ENV['LEGION_MODE'] = 'lite'
ENV['LEGION_LOCAL'] = 'true'
end
log_level = options[:log_level]
require 'legion/json'
require 'legion/settings'
directories = Legion::Settings::Loader.default_directories.select { |d| Dir.exist?(d) }
Legion::Settings.load(config_dirs: directories)
require 'legion'
require 'legion/service'
require 'legion/process'
clear_log_file unless options[:daemonize]
api = options.fetch(:api, true)
service_opts = { api: api }
service_opts[:log_level] = log_level if log_level
service_opts[:http_port] = options[:http_port] if options[:http_port]
service_opts[:role] = :lite if options[:lite]
Legion.instance_variable_set(:@service, Legion::Service.new(**service_opts))
Legion::Logging.info("Started Legion v#{Legion::VERSION}")
process_opts = {
daemonize: options[:daemonize],
pidfile: options[:pidfile],
logfile: options[:logfile],
time_limit: options[:time_limit]
}.compact
Legion::Process.new(process_opts).run!
end
|