From ddd2c689f629e2cf87128fe878c4e2b7c24a1d59 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Tue, 28 Apr 2020 15:14:33 +0200 Subject: [PATCH] nrepl! documentation! --- README.md | 25 +++++++++++++++++++++---- project.clj | 1 + src/wanijo/main.clj | 16 ++++++++++++---- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 401a1a7..e236b4d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Wanijo -> (Toki Pona) -> Wan: One, a, unite, make one -> Ijo: thing, something, object +> (Toki Pona) +> Wan: One, a, unite, make one +> Ijo: thing, something, object > Wanijo: Unite things ## How to develop @@ -12,7 +12,7 @@ You'll need: - JDK >= 8 - Leiningen >= 2.9 -### First time launch with fresh database +### First time launch with fresh a database - start a neo4j database with `lein neo4j` - start a repl with `lein repl` or similar @@ -28,6 +28,23 @@ You'll need: - run `wanijo.main/start-server-dev!` - the application is available on port `8080` +### Launch as a standalone + +- build the uberjar via `lein uberjar` +- start your neo4j database, preferably **not** via `lein neo4j` +- start the jar file via `java -jar [jar-file]-standalone.jar` +- if this is the first start with a fresh database, connect to the nREPL as described in the chapter "nREPL" and run the commands described in "First time launch with a fresh database" + +### nREPL + +When started via its `main` method, as is the uberjar case, an nREPL server is started with it. The default port is `7888`, but this can be configured via the `NREPL_PORT` environment variable. + +To connect via the command line, use the following command: + +``` +clj -Sdeps '{:deps {nrepl {:mvn/version "0.7.0"}}}' -m nrepl.cmdline --connect --host host --port port +``` + ### "Architecture" > Structure your application as it seems to fit your needs. Then call it architecture and pat yourself on the shoulder. You've achieved something! diff --git a/project.clj b/project.clj index 6b6a62a..1abd4aa 100644 --- a/project.clj +++ b/project.clj @@ -7,6 +7,7 @@ :dependencies [;;clojure core [org.clojure/clojure "1.10.1"] + [nrepl "0.7.0"] ;; static site [compojure "1.6.1"] diff --git a/src/wanijo/main.clj b/src/wanijo/main.clj index 494190c..7870e84 100644 --- a/src/wanijo/main.clj +++ b/src/wanijo/main.clj @@ -1,6 +1,7 @@ (ns wanijo.main (:require [ring.adapter.jetty :refer [run-jetty]] - [wanijo.handler :as wanijo-handler]) + [wanijo.handler :as wanijo-handler] + [nrepl.server :as nrepl]) (:gen-class)) (defonce server (atom nil)) @@ -24,6 +25,13 @@ (.stop @server))) (defn -main [& args] - (start-server! :port (Integer/valueOf (or (System/getenv "port") - "3080")) - :join? false)) + (let [nrepl-port (Integer/valueOf (or (System/getenv "NREPL_PORT") + "7888")) + web-port (Integer/valueOf (or (System/getenv "WEB_PORT") + "3080"))] + (println "starting nrepl on port " nrepl-port) + (nrepl/start-server :port nrepl-port) + + (println "starting web server on port " web-port) + (start-server! :port web-port + :join? false)))