Class: Mrsk::Commands::Accessory
- Defined in:
- lib/mrsk/commands/accessory.rb
Instance Attribute Summary collapse
-
#accessory_config ⇒ Object
readonly
Returns the value of attribute accessory_config.
Attributes inherited from Base
Instance Method Summary collapse
- #follow_logs(grep: nil) ⇒ Object
- #info ⇒ Object
-
#initialize(config, name:) ⇒ Accessory
constructor
A new instance of Accessory.
- #logs(since: nil, lines: nil, grep: nil) ⇒ Object
- #remove_container ⇒ Object
- #remove_image ⇒ Object
- #run ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config, name:) ⇒ Accessory
Returns a new instance of Accessory.
7 8 9 10 |
# File 'lib/mrsk/commands/accessory.rb', line 7 def initialize(config, name:) super(config) @accessory_config = config.accessory(name) end |
Instance Attribute Details
#accessory_config ⇒ Object (readonly)
Returns the value of attribute accessory_config.
4 5 6 |
# File 'lib/mrsk/commands/accessory.rb', line 4 def accessory_config @accessory_config end |
Instance Method Details
#follow_logs(grep: nil) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/mrsk/commands/accessory.rb', line 42 def follow_logs(grep: nil) run_over_ssh pipe( docker(:logs, service_name, "-t", "-n", "10", "-f", "2>&1"), ("grep '#{grep}'" if grep) ).join(" "), host: host end |
#info ⇒ Object
32 33 34 |
# File 'lib/mrsk/commands/accessory.rb', line 32 def info docker :ps, *service_filter end |
#logs(since: nil, lines: nil, grep: nil) ⇒ Object
36 37 38 39 40 |
# File 'lib/mrsk/commands/accessory.rb', line 36 def logs(since: nil, lines: nil, grep: nil) pipe \ docker(:logs, service_name, (" --since #{since}" if since), (" -n #{lines}" if lines), "-t", "2>&1"), ("grep '#{grep}'" if grep) end |
#remove_container ⇒ Object
49 50 51 |
# File 'lib/mrsk/commands/accessory.rb', line 49 def remove_container docker :container, :prune, "-f", *service_filter end |
#remove_image ⇒ Object
53 54 55 |
# File 'lib/mrsk/commands/accessory.rb', line 53 def remove_image docker :image, :prune, "-a", "-f", *service_filter end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mrsk/commands/accessory.rb', line 12 def run docker :run, "--name", service_name, "-d", "--restart", "unless-stopped", "-p", port, *env_args, *volume_args, *label_args, image end |
#start ⇒ Object
24 25 26 |
# File 'lib/mrsk/commands/accessory.rb', line 24 def start docker :container, :start, service_name end |
#stop ⇒ Object
28 29 30 |
# File 'lib/mrsk/commands/accessory.rb', line 28 def stop docker :container, :stop, service_name end |