Class: Mrsk::Commands::App

Inherits:
Base
  • Object
show all
Defined in:
lib/mrsk/commands/app.rb

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

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

Instance Method Details

#consoleObject



43
44
45
# File 'lib/mrsk/commands/app.rb', line 43

def console
  "ssh -t #{config.ssh_user}@#{config.primary_host} '#{exec("bin/rails", "c", interactive: true).join(" ")}'"
end

#exec(*command, interactive: false) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/mrsk/commands/app.rb', line 34

def exec(*command, interactive: false)
  docker :exec,
    ("-it" if interactive),
    "-e", redact("RAILS_MASTER_KEY=#{config.master_key}"),
    *config.env_args,
    config.service_with_version,
    *command
end

#infoObject



26
27
28
# File 'lib/mrsk/commands/app.rb', line 26

def info
  docker :ps, *service_filter
end

#list_containersObject



47
48
49
# File 'lib/mrsk/commands/app.rb', line 47

def list_containers
  docker :container, :ls, "-a", *service_filter
end

#logsObject



30
31
32
# File 'lib/mrsk/commands/app.rb', line 30

def logs
  [ "docker ps -q #{service_filter.join(" ")} | xargs docker logs -n 100 -t" ]
end

#remove_containersObject



51
52
53
# File 'lib/mrsk/commands/app.rb', line 51

def remove_containers
  docker :container, :prune, "-f", *service_filter
end

#remove_imagesObject



55
56
57
# File 'lib/mrsk/commands/app.rb', line 55

def remove_images
  docker :image, :prune, "-a", "-f", *service_filter
end

#run(role: :web) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mrsk/commands/app.rb', line 4

def run(role: :web)
  role = config.role(role)

  docker :run,
    "-d",
    "--restart unless-stopped",
    "--name", config.service_with_version,
    "-e", redact("RAILS_MASTER_KEY=#{config.master_key}"),
    *config.env_args,
    *role.label_args,
    config.absolute_image,
    role.cmd
end

#startObject



18
19
20
# File 'lib/mrsk/commands/app.rb', line 18

def start
  docker :start, config.service_with_version
end

#stopObject



22
23
24
# File 'lib/mrsk/commands/app.rb', line 22

def stop
  [ "docker ps -q #{service_filter.join(" ")} | xargs docker stop" ]
end