Drop concerns
Not enough reuse possible
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
require "mrsk/commands/base"
|
require "mrsk/commands/base"
|
||||||
require "mrsk/commands/concerns"
|
|
||||||
|
|
||||||
class Mrsk::Commands::App < Mrsk::Commands::Base
|
class Mrsk::Commands::App < Mrsk::Commands::Base
|
||||||
include Mrsk::Commands::Concerns::Executions
|
|
||||||
|
|
||||||
def run(role: :web)
|
def run(role: :web)
|
||||||
role = config.role(role)
|
role = config.role(role)
|
||||||
|
|
||||||
@@ -23,10 +20,6 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
docker :start, service_with_version
|
docker :start, service_with_version
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_container_id
|
|
||||||
docker :ps, "-q", *service_filter
|
|
||||||
end
|
|
||||||
|
|
||||||
def stop
|
def stop
|
||||||
pipe current_container_id, xargs(docker(:stop))
|
pipe current_container_id, xargs(docker(:stop))
|
||||||
end
|
end
|
||||||
@@ -35,6 +28,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
docker :ps, *service_filter
|
docker :ps, *service_filter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def logs(since: nil, lines: nil, grep: nil)
|
def logs(since: nil, lines: nil, grep: nil)
|
||||||
pipe \
|
pipe \
|
||||||
current_container_id,
|
current_container_id,
|
||||||
@@ -50,6 +44,38 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
).join(" "), host: host
|
).join(" "), host: host
|
||||||
end
|
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:)
|
def container_id_for(container_name:)
|
||||||
docker :container, :ls, "-a", "-f", "name=#{container_name}", "-q"
|
docker :container, :ls, "-a", "-f", "name=#{container_name}", "-q"
|
||||||
end
|
end
|
||||||
@@ -68,6 +94,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
"head -n 1"
|
"head -n 1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def list_containers
|
def list_containers
|
||||||
docker :container, :ls, "-a", *service_filter
|
docker :container, :ls, "-a", *service_filter
|
||||||
end
|
end
|
||||||
@@ -90,6 +117,7 @@ class Mrsk::Commands::App < Mrsk::Commands::Base
|
|||||||
docker :image, :prune, "-a", "-f", *service_filter
|
docker :image, :prune, "-a", "-f", *service_filter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def service_with_version(version = nil)
|
def service_with_version(version = nil)
|
||||||
if version
|
if version
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
module Mrsk::Commands::Concerns
|
|
||||||
end
|
|
||||||
|
|
||||||
require "mrsk/commands/concerns/executions"
|
|
||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user