Graceful exit.
This commit is contained in:
parent
c476d89f69
commit
96eb605682
@ -181,6 +181,11 @@ class DNSManager::Client < IPC
|
||||
parse_message [ Response::Success ], read
|
||||
end
|
||||
|
||||
def admin_exit
|
||||
request = Request::Exit.new
|
||||
send_now request
|
||||
end
|
||||
|
||||
#
|
||||
# Utils
|
||||
#
|
||||
|
@ -32,6 +32,7 @@ class Actions
|
||||
@the_call["admin-migration-script"] = ->admin_migration_script
|
||||
@the_call["admin-generate-all-zonefiles"] = ->admin_generate_all_zonefiles
|
||||
@the_call["admin-provide-domain"] = ->admin_provide_domain
|
||||
@the_call["admin-exit"] = ->admin_exit
|
||||
|
||||
# Domain operations.
|
||||
@the_call["user-domain-add"] = ->user_domain_add
|
||||
@ -155,6 +156,12 @@ class Actions
|
||||
puts "error for provide_domain: #{e.message}"
|
||||
end
|
||||
|
||||
def admin_exit
|
||||
@dnsmanagerd.admin_exit
|
||||
rescue e
|
||||
puts "error for provide_domain: #{e.message}"
|
||||
end
|
||||
|
||||
def user_domain_add
|
||||
domains = Context.args.not_nil!
|
||||
domains.each do |domain|
|
||||
|
@ -131,6 +131,14 @@ def parsing_cli(authd_config : Baguette::Configuration::Auth)
|
||||
parser.banner = "COMMAND: admin migration-script user-db.txt"
|
||||
unrecognized_args_to_context_args.call parser, 1, nil
|
||||
end
|
||||
|
||||
# Kill the service.
|
||||
parser.on("exit", "Kill the service.") do
|
||||
Baguette::Log.info "kill the service."
|
||||
Context.command = "admin-exit"
|
||||
parser.banner = "COMMAND: exit"
|
||||
unrecognized_args_to_context_args.call parser, nil, 0
|
||||
end
|
||||
end
|
||||
|
||||
# User section.
|
||||
|
@ -91,4 +91,23 @@ class DNSManager::Request
|
||||
end
|
||||
end
|
||||
DNSManager.requests << GenerateZoneFile
|
||||
|
||||
IPC::JSON.message Exit, 248 do
|
||||
def initialize
|
||||
end
|
||||
|
||||
def to_s(io : IO)
|
||||
super io
|
||||
end
|
||||
|
||||
def handle(dnsmanagerd : DNSManager::Service, event : IPC::Event) : IPC::JSON
|
||||
user = dnsmanagerd.get_logged_user event
|
||||
return Response::ErrorUserNotLogged.new unless user
|
||||
dnsmanagerd.storage.user_must_be_admin! user.uid
|
||||
|
||||
Baguette::Log.warning "exit requested, bye"
|
||||
exit 0
|
||||
end
|
||||
end
|
||||
DNSManager.requests << Exit
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user