Remove service directory on kamal remove

This commit is contained in:
Donal McBreen
2024-09-12 16:01:49 +01:00
parent d7d6fa34b0
commit b8972a6833
4 changed files with 22 additions and 2 deletions

View File

@@ -231,6 +231,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
stop
remove_containers
remove_images
remove_service_directory
end
end
@@ -272,6 +273,20 @@ class Kamal::Cli::App < Kamal::Cli::Base
end
end
desc "remove_service_directory", "Remove the service directory from servers", hide: true
def remove_service_directory
with_lock do
on(KAMAL.hosts) do |host|
roles = KAMAL.roles_on(host)
roles.each do |role|
execute *KAMAL.auditor.record("Removed #{KAMAL.config.service_directory} on all servers", role: role), verbosity: :debug
execute *KAMAL.server.remove_service_directory
end
end
end
end
desc "version", "Show app version currently running on servers"
def version
on(KAMAL.hosts) do |host|

View File

@@ -181,8 +181,8 @@ class Kamal::Cli::Main < Kamal::Cli::Base
def remove
confirming "This will remove all containers and images. Are you sure?" do
with_lock do
invoke "kamal:cli:proxy:remove", [], options.without(:confirmed)
invoke "kamal:cli:app:remove", [], options.without(:confirmed)
invoke "kamal:cli:proxy:remove", [], options.without(:confirmed)
invoke "kamal:cli:accessory:remove", [ "all" ], options
invoke "kamal:cli:registry:logout", [], options.without(:confirmed).merge(skip_local: true)
end

View File

@@ -1,5 +1,9 @@
class Kamal::Commands::Server < Kamal::Commands::Base
def ensure_service_directory
[ :mkdir, "-p", config.service_directory ]
make_directory config.service_directory
end
def remove_service_directory
remove_directory config.service_directory
end
end