The lein-webrepl plugin provides a web page based alternative to classical shell based REPL interface provided by 'lein repl' command. It requires Leiningen v2.0 and Clojure 1.3.0. Here is the usage guide:
A simple run transcript, a browser window will pop up and connect to
More information at lein-webrepl GitHub page.
The ringMon monitoring page now has a simple chat support. There is one chat nick available for each active nREPL session. To find out more info about active sessions expand ReplSessions section of the monitoring data tree.
You will be given default unique nick when your session is created. To change it uncheck 'Confirm', modify 'Chat as' and check 'Confirm' again. Your nick will be remembered on the server side until this application is restarted.
The 'Send' button will send the contents the nREPL input window (or just a selection, if active) either to all connected people or to a single recipient. Other people messages will appear in nREPL output window.
Chat functions are also accessible to your Clojure scripts via ringmon.api namespace:
Here is a simple script to change your chat nick:
The ringMon is a Ring middleware that adds remote diagnostic and REPL interaction capability to Clojure web applications that are based on Ring library or higher level web frameworks such as Noir or Compojure.
It injects a single monitoring page at /ringmon/monview.html
The page periodically displays raw JMX data of interest in a tree like structure. It also shows derived values such as CPU load that is calculated by sampling JMX roperty OperatingSystem.ProcessCpuTime every 2 seconds and AJAX requests statistics.
Moreover, the page provides full featured nREPL front end, with syntax coloured editor, command history and persistent sessions. The actual nREPL server runs in the context of this application. The ringMon web page uses AJAX to submit Clojure forms from input window (upon pressing Ctrl-Enter), displaying nREPL responses in a separate output window. The script output from nREPL server is sampled at variable rate depending of output activity. Since nREPL session is persistent the nREPL output is buffered even when web client (browser) is disconnected, and will be sent out on next reconnection. Currently only one session is kept for particular browser per each client computer. Nothing horrible happens if you open multiple windows within the same browser, only that nREPL output will randomly be sprinkled across multiple output windows. This restriction will be removed soon, but for the time being using Chrome + Firefox + Safari will give you 3 simultaneous sessions :).
You can submit multiple forms (scripts) without waiting for the previous ones to finish - they will be queued by nREPL server. The 'Interrupt' button will try (and in most cases succeed) to break the current script execution and possibly schedule the next one in the queue, if any. Note that if script creates other threads they may not be interrupted, and that their eventual output will not be captured by nREPL server - it will go to the stdout of the shell that started your Clojure application. If you are on Heroku, you can catch it with 'heroku logs -t' command.
Only small amount of changes was required to add ringMon capability to this application:
- include [noirmon "0.1.0-SNAPSHOT"] in project.clj
* add the middleware itself before starting the server:
* put convenient link to access the monitoring page (optional)