/system-api-immutant-example

Example for a defsystem with separate API and site middleware

Primary LanguageClojureEclipse Public License 1.0EPL-1.0

Example project

What is this?

This project gives you an overview of how you might want to structure a Raamwerk web app with separate API and site middeware. 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 Boot.

Instructions

Development

Run the development pipeline from the command line:

$ boot dev

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

(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)))

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:

boot.user=> (go)

You’re all set now. Your local web app can be found on 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:

boot.user=> (reset)

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:

$ boot dev-run

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

Production

Package an uberjar:

$ boot build

You are ready to launch:

$ java -jar -Dhttp.port=8000 -Drepl.port=8001 target/myproject-1.0.0.jar

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.