Skip to content

Commit

Permalink
fluree.server.main -> fluree.server
Browse files Browse the repository at this point in the history
  • Loading branch information
zonotope committed Feb 9, 2025
1 parent 45d5725 commit 7ed1e31
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
(defn uber [_]
(bb/uber {:lib lib
:version version
:main 'fluree.server.main}))
:main 'fluree.server}))
7 changes: 4 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{:deps {org.clojure/clojure {:mvn/version "1.11.3"}
org.clojure/core.async {:mvn/version "1.6.681"}
com.fluree/db {:git/url "https://github.com/fluree/db.git"
:git/sha "8c99b2b2de0c0c5d94c52e1586ad7cfd978690f8"}
;; com.fluree/db {:git/url "https://github.com/fluree/db.git"
;; :git/sha "8c99b2b2de0c0c5d94c52e1586ad7cfd978690f8"}
com.fluree/db {:local/root "../db"}
com.fluree/json-ld {:git/url "https://github.com/fluree/json-ld.git"
:git/sha "73a990a4b803d0b4cfbbbe4dc16275b39a3add4e"}

Expand Down Expand Up @@ -51,7 +52,7 @@
integrant/repl {:mvn/version "0.3.3"}}}

:run-dev
{:exec-fn fluree.server.main/run-server
{:exec-fn fluree.server/run
:exec-args {:profile :dev}}

:test
Expand Down
37 changes: 22 additions & 15 deletions src/fluree/server/main.clj → src/fluree/server.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(ns fluree.server.main
(ns fluree.server
(:require [clojure.string :as str]
[clojure.tools.cli :as cli]
[fluree.db.util.log :as log]
Expand Down Expand Up @@ -41,6 +41,12 @@
parsed-opts
(update parsed-opts :errors conj multiple-configuration-error)))

(defn parse-cli
[args]
(-> args
(cli/parse-opts cli-options)
validate-opts))

(defn usage
[summary]
(str/join \newline ["Fluree Ledger Server"
Expand All @@ -57,7 +63,7 @@
(println message)
(System/exit status))

(defn start-server
(defn start
[{:keys [profile] :as options}]
(if-let [config-string (:string options)]
(do (log/info "Starting Fluree server from command line configuration with profile:"
Expand All @@ -73,18 +79,19 @@
(do (log/info "Starting Fluree server with profile:" profile)
(system/start profile))))))

(defn run
[{:keys [options errors summary]}]
(cond (seq errors)
(let [msg (error-message errors)]
(exit 1 msg))

(:help options)
(let [msg (usage summary)]
(exit 0 msg))

:else
(start options)))

(defn -main
[& args]
(let [{:keys [options errors summary]} (-> args
(cli/parse-opts cli-options)
validate-opts)]
(cond (seq errors)
(let [msg (error-message errors)]
(exit 1 msg))

(:help options)
(let [msg (usage summary)]
(exit 0 msg))

:else
(start-server options))))
(-> args parse-cli run))

0 comments on commit 7ed1e31

Please sign in to comment.