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

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

#detailsObject



47
48
49
# File 'lib/mrsk/cli/traefik.rb', line 47

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

#logsObject



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

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



10
11
12
13
14
15
16
# File 'lib/mrsk/cli/traefik.rb', line 10

def reboot
  with_lock do
    stop
    remove_container
    boot
  end
end

#removeObject



76
77
78
79
80
81
82
# File 'lib/mrsk/cli/traefik.rb', line 76

def remove
  with_lock do
    stop
    remove_container
    remove_image
  end
end

#remove_containerObject



85
86
87
88
89
90
91
92
# File 'lib/mrsk/cli/traefik.rb', line 85

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



95
96
97
98
99
100
101
102
# File 'lib/mrsk/cli/traefik.rb', line 95

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



39
40
41
42
43
44
# File 'lib/mrsk/cli/traefik.rb', line 39

def restart
  with_lock do
    stop
    start
  end
end

#startObject



19
20
21
22
23
24
25
26
# File 'lib/mrsk/cli/traefik.rb', line 19

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



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

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