Sitelet https://github.com/danielsz/system/tree/master/examples/boot
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
* Example project

** What is this?
This project gives you an overview of how you might want to structure a Clojure web app with the [[https://github.com/danielsz/system/][system]] library.
The example project starts a web server in development mode, and a web server + remote repl in production. 
The build tool used in this project is [[http://boot-clj.com/][Boot]]. 
** Instructions
*** Development

Run the development pipeline from the command line:
#+BEGIN_SRC bash
$ boot dev
#+END_SRC

Which is actually a ~boot~ task, defined in ~build.boot~:

#+BEGIN_SRC clojure
(deftask dev
  "Run a restartable system in the Repl"
  []
  (comp
   (environ :env {:http-port 3000})
   (watch :verbose true)
   (system :sys #'dev-system :auto true)
   (repl :server true)))
#+END_SRC

The ~:auto~ option tells ~system~ to start your application and automatically reload namespaces when you change them. You can manage restarts manually if you prefer. In that case, connect to your REPL from your favorite editor, and in the boot.user namespace, type: 

#+BEGIN_SRC clojure 
boot.user=> (go)
#+END_SRC

You’re all set now. Your local web app can be found on [[http://localhost:300][localhost]] on port 3000. Now you can edit your source files and make changes. Save and restart your application whenever you want a clean slate:

#+BEGIN_SRC clojure 
boot.user=> (reset)
#+END_SRC

_Note_: If you have set ~:auto~ to true, you don’t need to restart manually. Namespaces are reloaded when source files are saved, and the ~:files~ option allow you to specify files that warrant a restart at the component level.

If you want to run your development system from the command line (without opening a REPL), type:
#+BEGIN_SRC sh
$ boot dev-run
#+END_SRC

_Note_: Please make sure ~build.boot~ requires the system var in its namespace declarations. 

*** Production
Package an uberjar:
#+BEGIN_SRC sh
$ boot build
#+END_SRC

You are ready to launch:
#+BEGIN_SRC sh
$ java -jar -Dhttp.port=8000 -Drepl.port=8001 target/myproject-1.0.0.jar
#+END_SRC

Your web app will be found on port 8000, and on port 8001 you will be able to connect to its repl for remote debugging.