Class: AethernalAgent::Cli::Services

Inherits:
Thor
  • Object
show all
Includes:
Utils
Defined in:
lib/aethernal_agent/cli/services.rb

Instance Attribute Summary collapse

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 Attribute Details

#userObject

Returns the value of attribute user.



6
7
8
# File 'lib/aethernal_agent/cli/services.rb', line 6

def user
  @user
end

Instance Method Details

#listObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/aethernal_agent/cli/services.rb', line 43

def list
  service_files = `ls ~/.config/systemd/user/*.service`.split("\n")
  result = service_files.collect do |s|
    pn = Pathname.new(s)
    app_name = pn.basename
    status = systemd_text_for_service(app_name).split("\n")[2].strip
    [app_name, status]
  end
  table = Terminal::Table.new :headings => ['Service', 'Status'], :rows => result
  puts table
end

#restart(app) ⇒ Object



20
21
22
# File 'lib/aethernal_agent/cli/services.rb', line 20

def restart(app)
  run_systemd_plain("restart", app)
end

#start(app) ⇒ Object



10
11
12
# File 'lib/aethernal_agent/cli/services.rb', line 10

def start(app)
  run_systemd_plain("start", app)
end

#start_allObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/aethernal_agent/cli/services.rb', line 31

def start_all
  puts "Starting all known services"
  service_files = `ls ~/.config/systemd/user/*.service`.split("\n")
  result = service_files.collect do |s|
    pn = Pathname.new(s)
    app_name = pn.basename
    puts "Starting #{app_name}"
    run_systemd_plain("start", app_name)
  end
end

#status(app) ⇒ Object



25
26
27
28
# File 'lib/aethernal_agent/cli/services.rb', line 25

def status(app)
  result = run_systemd_plain("status", app)
  puts result
end

#stop(app) ⇒ Object



15
16
17
# File 'lib/aethernal_agent/cli/services.rb', line 15

def stop(app)
  run_systemd_plain("stop", app)
end