Skip to content

Instantly share code, notes, and snippets.

@zoka
Created March 27, 2012 01:02
Show Gist options
  • Save zoka/2211345 to your computer and use it in GitHub Desktop.
Save zoka/2211345 to your computer and use it in GitHub Desktop.
lein-webrepl
$ lein2 help webrepl
Start a web REPL session with the current project or standalone.
USAGE: lein2 webrepl [-n] [port] | [port] [-n]
This will launch an nREPL server behind the freshly started Jetty
instance and then open a fresh window of your default browser, connecting it
to the page featuring the nREPL front end.
The port value the Jetty is started on will be taken from command line,
if supplied. The LEIN_REPL_PORT environment variable is checked next,
then the value for the :repl-port key in project.clj, and finally it
will default to 8888. If port value is set to be zero, it is chosen randomly.
If option -n is supplied, no browser window will be opened. This is needed
when application is running on a remote host or when there is already
a browser window awaiting connection from the previous run.
For the time being (hopefully not for long) only one session
is supported per browser/per client computer, so if you have 2 or more windows
within the web browser connected to the same server, nREPL output will
be randomly sprinkled accros all of them. The workaround is to use
another browser type side by side (tested on Chrome, Firefox and Safari).
Note that REPL sessions are persistent - if you disconnect the browser for a
while and then load the REPL page again, all buffered session output
will be displayed in the output window.
If you run this command inside of a project, it will be run in
the context of that classpath and it will activate namespaces specified
by :main and :repl-init keys in project.clj when REPL session is established.
If the command is run outside of a project, it'll be standalone and the
classpath will be that of Leiningen.
$ lein2 webrepl
Compiling noir.server
Compilation succeeded.
[ringMon server] starting with: {:local-repl true, :lein-webrepl {:main noir.server}}
2012-03-27 11:57:59.946:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2012-03-27 11:57:59.947:INFO::jetty-6.1.25
2012-03-27 11:57:59.961:INFO::Started SocketConnector@0.0.0.0:8888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment