Skip to content

Commit

Permalink
use forceclose in down() per default
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaensel committed Feb 18, 2024
1 parent 1aa2a73 commit acb5a26
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using HTTP, Sockets, HTTP.WebSockets
import Millboard, Distributed, Logging
import Genie
import Distributed
import HTTP.Servers.Listener
import HTTP.Servers: Listener, forceclose


"""
Expand Down Expand Up @@ -253,18 +253,19 @@ end
Shuts down the servers optionally indicating which of the `webserver` and `websockets` servers to be stopped.
It does not remove the servers from the `SERVERS` collection. Returns the collection.
"""
function down(; webserver::Bool = true, websockets::Bool = true) :: Vector{ServersCollection}
function down(; webserver::Bool = true, websockets::Bool = true, force::Bool = true) :: Vector{ServersCollection}
for i in 1:length(SERVERS)
down(SERVERS[i]; webserver, websockets)
down(SERVERS[i]; webserver, websockets, force)
end

SERVERS
end


function down(server::ServersCollection; webserver::Bool = true, websockets::Bool = true) :: ServersCollection
webserver && !isnothing(server.webserver) && isopen(server.webserver) && close(server.webserver)
websockets && !isnothing(server.websockets) && isopen(server.websockets) && close(server.websockets)
function down(server::ServersCollection; webserver::Bool = true, websockets::Bool = true, force::Bool = true) :: ServersCollection
close_cmd = force ? forceclose : close
webserver && !isnothing(server.webserver) && isopen(server.webserver) && close_cmd(server.webserver)
websockets && !isnothing(server.websockets) && isopen(server.websockets) && close_cmd(server.websockets)

server
end
Expand Down

0 comments on commit acb5a26

Please sign in to comment.