This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-04
Channels
- # announcements (4)
- # aws (3)
- # babashka (58)
- # beginners (59)
- # biff (6)
- # cider (3)
- # clj-kondo (48)
- # clj-on-windows (1)
- # cljdoc (1)
- # clojure (136)
- # clojure-europe (19)
- # clojure-gamedev (7)
- # clojure-germany (2)
- # clojure-nl (7)
- # clojure-norway (1)
- # clojure-portugal (1)
- # clojure-uk (4)
- # clojurescript (41)
- # community-development (2)
- # core-async (5)
- # cursive (10)
- # data-oriented-programming (1)
- # data-science (1)
- # datahike (5)
- # datomic (60)
- # docker (2)
- # emacs (13)
- # figwheel-main (19)
- # fulcro (12)
- # graalvm (9)
- # holy-lambda (41)
- # honeysql (14)
- # introduce-yourself (3)
- # jobs (4)
- # lsp (11)
- # nrepl (1)
- # off-topic (9)
- # other-languages (2)
- # pathom (22)
- # portal (5)
- # re-frame (17)
- # remote-jobs (4)
- # reveal (14)
- # shadow-cljs (1)
- # tools-build (7)
- # tools-deps (47)
- # xtdb (8)
- # yada (2)
If I start my server with clojure -A:dev:xtdb -M -m com.example.components.server
, how do I connect to that same REPL? For example, if I want to inspect the (mount/running-states)
.
here's how to start one with mount:
(ns co.app.nrepl-server
(:require
[co.app.server.config :refer [config]]
[mount.core :refer [defstate]]
[nrepl.server :refer [start-server stop-server]]))
(defstate nrepl-server
:start
(let [{keys [port]} (::config config)]
(start-server :port port))
:stop
(stop-server nrepl-server))
(and of course add the dep and include this ns in your server entry)I see, so how the billing app has it here https://github.com/holyjak/fulcro-billing-app/blob/568bf28552989e1e611773b2d946c9990e1edc3d/src/shared/billing_app/components/repl_server.clj#L9.
I would use clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.28.3"}}}' -m nrepl.cmdline --middleware '["cider.nrepl/cider-middleware"]' --interactive
if nrepl is needed sometimes, instead of adding code for it.
@U8ZQ1J1RR so first I would launch my server and then use that command to access the nrepl? I'm doing that and it still doesn't seem to be the same REPL as my running server.
$ clj -A:dev:xtdb -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0"} cider/cider-nrepl {:mvn/version "0.28.3"}}}' -m nrepl.cmdline --middleware '["cider.nrep l/cider-middleware"]' --interactive
WARNING: Implicit use of clojure.main with options is deprecated, use -M
nREPL server started on port 42755 on host localhost -
nREPL 0.9.0
Clojure 1.10.3
OpenJDK 64-Bit Server VM 11.0.15+10-Ubuntu-0ubuntu0.20.04.1
Interrupt: Control+C
Exit: Control+D or (exit) or (quit)
user=> (use '[mount.core :as mount])
nil
user=> (use '[com.example.components.server :as server])
2022-05-04T18:46:31.120Z ubuntu-focal DEBUG [com.fulcrologic.rad.blob:197] - Wrapping persist-images with image keys #{}
nil
user=> (mount/running-states)
#{}
Or do you mean that I should add that to my current launch command when starting the server?Yes, you cannot bolt on a repl on a different process. But you can launch it purely on command line without making code changes
Okay, that's a useful option indeed if I'm just using the REPL occasionally to debug stuff. Thank you for the tip. I wonder, is using the REPL a common thing in production?
I don't think so, but that's just what I hear in the local bubble. Sean Corfield is a big proponent of repl in production, and I think they have the socket repl always running
This handy practicalli repo has an https://github.com/practicalli/clojure-deps-edn/blob/live/deps.edn#L107-L114= defined for exactly what you suggested @U8ZQ1J1RR. Along with a few other useful ones that are related. Posting here for reference.