Skip to content

Commit

Permalink
clean up all ssh connections and exit cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
retrogradeorbit committed May 18, 2020
1 parent 578d72b commit e5c8599
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/clj/spire/core.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(ns spire.core
(:require [spire.state]
(:require [spire.state :as state]
[spire.config :as config]
[spire.output.core :as output]
[spire.utils :as utils]
[spire.eval :as eval]
[spire.state :as state]
[spire.transport :as transport]
[spire.output.default]
[spire.output.events]
[spire.output.quiet]
Expand Down Expand Up @@ -82,4 +82,5 @@
:else
(println (usage summary)))))
(finally
(transport/disconnect-all!)
(shutdown-agents))))
6 changes: 6 additions & 0 deletions src/clj/spire/transport.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
(when debug (prn 'disconnect connection))
(.disconnect connection))

(defn disconnect-all! []
(let [[connections _] (reset-vals! state/ssh-connections {})]
(doall
(for [[_ {:keys [connection]}] connections]
(disconnect connection)))))

(defn open-connection [host-config]
(when debug (prn 'open-connection host-config))
(let [conn-key (ssh/host-config-to-connection-key host-config)
Expand Down

0 comments on commit e5c8599

Please sign in to comment.