diff --git a/lib/mrsk/commands/app.rb b/lib/mrsk/commands/app.rb index 00f5c5c2..d3140cb1 100644 --- a/lib/mrsk/commands/app.rb +++ b/lib/mrsk/commands/app.rb @@ -1,9 +1,6 @@ require "mrsk/commands/base" -require "mrsk/commands/concerns" class Mrsk::Commands::App < Mrsk::Commands::Base - include Mrsk::Commands::Concerns::Executions - def run(role: :web) role = config.role(role) @@ -23,10 +20,6 @@ class Mrsk::Commands::App < Mrsk::Commands::Base docker :start, service_with_version end - def current_container_id - docker :ps, "-q", *service_filter - end - def stop pipe current_container_id, xargs(docker(:stop)) end @@ -35,6 +28,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base docker :ps, *service_filter end + def logs(since: nil, lines: nil, grep: nil) pipe \ current_container_id, @@ -50,6 +44,38 @@ class Mrsk::Commands::App < Mrsk::Commands::Base ).join(" "), host: host end + + def execute_in_existing_container(*command, interactive: false) + docker :exec, + ("-it" if interactive), + config.service_with_version, + *command + end + + def execute_in_new_container(*command, interactive: false) + docker :run, + ("-it" if interactive), + "--rm", + *rails_master_key_arg, + *config.env_args, + *config.volume_args, + config.absolute_image, + *command + end + + def execute_in_existing_container_over_ssh(*command, host:) + run_over_ssh execute_in_existing_container(*command, interactive: true).join(" "), host: host + end + + def execute_in_new_container_over_ssh(*command, host:) + run_over_ssh execute_in_new_container(*command, interactive: true).join(" "), host: host + end + + + def current_container_id + docker :ps, "-q", *service_filter + end + def container_id_for(container_name:) docker :container, :ls, "-a", "-f", "name=#{container_name}", "-q" end @@ -68,6 +94,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base "head -n 1" end + def list_containers docker :container, :ls, "-a", *service_filter end @@ -90,6 +117,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base docker :image, :prune, "-a", "-f", *service_filter end + private def service_with_version(version = nil) if version diff --git a/lib/mrsk/commands/concerns.rb b/lib/mrsk/commands/concerns.rb deleted file mode 100644 index 789fe922..00000000 --- a/lib/mrsk/commands/concerns.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Mrsk::Commands::Concerns -end - -require "mrsk/commands/concerns/executions" diff --git a/lib/mrsk/commands/concerns/executions.rb b/lib/mrsk/commands/concerns/executions.rb deleted file mode 100644 index dd7be827..00000000 --- a/lib/mrsk/commands/concerns/executions.rb +++ /dev/null @@ -1,27 +0,0 @@ -module Mrsk::Commands::Concerns::Executions - def execute_in_existing_container(*command, interactive: false) - docker :exec, - ("-it" if interactive), - config.service_with_version, - *command - end - - def execute_in_new_container(*command, interactive: false) - docker :run, - ("-it" if interactive), - "--rm", - *rails_master_key_arg, - *config.env_args, - *config.volume_args, - config.absolute_image, - *command - end - - def execute_in_existing_container_over_ssh(*command, host:) - run_over_ssh execute_in_existing_container(*command, interactive: true).join(" "), host: host - end - - def execute_in_new_container_over_ssh(*command, host:) - run_over_ssh execute_in_new_container(*command, interactive: true).join(" "), host: host - end -end