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
6
7
8
9
10
# File 'lib/mrsk/cli/traefik.rb', line 3

def boot
  with_lock do
    on(MRSK.traefik_hosts) do
      execute *MRSK.registry.
      execute *MRSK.traefik.run, raise_on_non_zero_exit: false
    end
  end
end

#detailsObject



50
51
52
# File 'lib/mrsk/cli/traefik.rb', line 50

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

#logsObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mrsk/cli/traefik.rb', line 59

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



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

def reboot
  with_lock do
    stop
    remove_container
    boot
  end
end

#removeObject



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

def remove
  with_lock do
    stop
    remove_container
    remove_image
  end
end

#remove_containerObject



88
89
90
91
92
93
94
95
# File 'lib/mrsk/cli/traefik.rb', line 88

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

#remove_imageObject



98
99
100
101
102
103
104
105
# File 'lib/mrsk/cli/traefik.rb', line 98

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

#restartObject



42
43
44
45
46
47
# File 'lib/mrsk/cli/traefik.rb', line 42

def restart
  with_lock do
    stop
    start
  end
end

#startObject



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

def start
  with_lock do
    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
end

#stopObject



32
33
34
35
36
37
38
39
# File 'lib/mrsk/cli/traefik.rb', line 32

def stop
  with_lock do
    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
end