Class: Mrsk::Cli::Traefik

Inherits:
Base
  • Object
show all
Defined in:
lib/mrsk/cli/traefik.rb

Instance Method Summary collapse

Methods inherited from Base

exit_on_failure?, #initialize

Constructor Details

This class inherits a constructor from Mrsk::Cli::Base

Instance Method Details

#bootObject



3
4
5
# File 'lib/mrsk/cli/traefik.rb', line 3

def boot
  on(MRSK.traefik_hosts) { execute *MRSK.traefik.run, raise_on_non_zero_exit: false }
end

#detailsObject



37
38
39
# File 'lib/mrsk/cli/traefik.rb', line 37

def details
  on(MRSK.traefik_hosts) { |host| puts_by_host host, capture_with_info(*MRSK.traefik.info), type: "Traefik" }
end

#logsObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/mrsk/cli/traefik.rb', line 46

def logs
  grep = options[:grep]

  if options[:follow]
    run_locally do
      info "Following logs on #{MRSK.primary_host}..."
      info MRSK.traefik.follow_logs(host: MRSK.primary_host, grep: grep)
      exec MRSK.traefik.follow_logs(host: MRSK.primary_host, grep: grep)
    end
  else
    since = options[:since]
    lines = options[:lines].presence || ((since || grep) ? nil : 100) # Default to 100 lines if since or grep isn't set

    on(MRSK.traefik_hosts) do |host|
      puts_by_host host, capture(*MRSK.traefik.logs(since: since, lines: lines, grep: grep)), type: "Traefik"
    end
  end
end

#rebootObject



8
9
10
11
12
# File 'lib/mrsk/cli/traefik.rb', line 8

def reboot
  invoke :stop
  invoke :remove_container
  invoke :boot
end

#removeObject



66
67
68
69
70
# File 'lib/mrsk/cli/traefik.rb', line 66

def remove
  invoke :stop
  invoke :remove_container
  invoke :remove_image
end

#remove_containerObject



73
74
75
76
77
78
# File 'lib/mrsk/cli/traefik.rb', line 73

def remove_container
  on(MRSK.traefik_hosts) do
    execute *MRSK.auditor.record("Removed traefik container"), verbosity: :debug
    execute *MRSK.traefik.remove_container
  end
end

#remove_imageObject



81
82
83
84
85
86
# File 'lib/mrsk/cli/traefik.rb', line 81

def remove_image
  on(MRSK.traefik_hosts) do
    execute *MRSK.auditor.record("Removed traefik image"), verbosity: :debug
    execute *MRSK.traefik.remove_image
  end
end

#restartObject



31
32
33
34
# File 'lib/mrsk/cli/traefik.rb', line 31

def restart
  invoke :stop
  invoke :start
end

#startObject



15
16
17
18
19
20
# File 'lib/mrsk/cli/traefik.rb', line 15

def start
  on(MRSK.traefik_hosts) do
    execute *MRSK.auditor.record("Started traefik"), verbosity: :debug
    execute *MRSK.traefik.start, raise_on_non_zero_exit: false
  end
end

#stopObject



23
24
25
26
27
28
# File 'lib/mrsk/cli/traefik.rb', line 23

def stop
  on(MRSK.traefik_hosts) do
    execute *MRSK.auditor.record("Stopped traefik"), verbosity: :debug
    execute *MRSK.traefik.stop, raise_on_non_zero_exit: false
  end
end