Class: AethernalAgent::Webserver::Core

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/aethernal_agent/webserver/core.rb

Instance Method Summary collapse

Methods included from Utils

#apt_running?, #check_manifest, #container_domain, #current_xdg_runtime_dir, #docker_container_name, #get_current_uid, #get_global_config, #global_config_path, #port_is_free, #prepare_test_config, #print_system, #random_port, #random_string, #run_as, #run_command, #run_systemd_plain, #set_global_config, #systemd_text_for_service, #ubuntu_release, #wait_on_apt, #wait_on_file, #wait_on_port

Instance Method Details

#startObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/aethernal_agent/webserver/core.rb', line 9

def start
  username = get_global_config("web_username")
  password = get_global_config("web_password")
  if username.nil? || password.nil?
    AethernalAgent.logger.info("No username or password found in config, creating one.")

    username = random_string
    password = random_string

    set_global_config("web_username", username)
    set_global_config("web_password", password)
  end

  AethernalAgent.logger.info("Starting AethernalAgent - v#{AethernalAgent::VERSION}")

  pool = AethernalAgent::OperationPool.new(3)
  threads = []
  threads << Thread.new { AethernalAgent::Webserver::Api.start(username, password, pool) }
  threads << Thread.new { pool.start }
  threads.each(&:join)
end