Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jlangch committed Sep 19, 2023
1 parent a05b8b5 commit 507eb54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


;; start ArangoDB
(defn start [cname version mapped-port root-passwd memory cores]
(defn start [cname version mapped-port root-passwd memory cores log]
{ :pre [(string? cname)
(string? version)
(or (int? mapped-port) (long? mapped-port))
Expand All @@ -40,23 +40,25 @@
(let [envs ["ARANGO_ROOT_PASSWORD=~{root-passwd}"
"ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY=~{memory}"
"ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES=~(long cores)"]
args ["--server.endpoint tcp://0.0.0.0:8259"]]
args ["--server.endpoint tcp://0.0.0.0:8259"]
log (or log default-log)]
(cargo/start cname version mapped-port envs args arangodb-ready? log)))


;; stop ArangoDB
(defn stop [cname]
(defn stop [cname log]
{ :pre [(string? cname)] }

(cargo/stop cname log))
(let [log (or log default-log)]
(cargo/stop cname log)))


;; ---------------------------------------------------------------------------
;; utils
;; ---------------------------------------------------------------------------

(defn log [s]
(println "ArangoDB: " s))
(defn default-log [s]
(println "ArangoDB:" s))

(defn arangodb-ready? [cname]
(-> (last-log-line cname)
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/com/github/jlangch/venice/cargo.venice
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@
{ :pre [(string? cname)
(or (nil? log) (fn? log))] }

(when (d/container-running-with-name? cname)
(stop-container cname log)))
(let [log (or log (fn [s] nil))]
(when (d/container-running-with-name? cname)
(stop-container cname log))))


;; ---------------------------------------------------------------------------
Expand Down

0 comments on commit 507eb54

Please sign in to comment.