Skip to content
Kevin W. van Rooijen edited this page Jul 19, 2020 · 13 revisions

Setting up

Duct provides a Leiningen template that makes is easy to get going. To create a bare-bones project, run:

lein new duct hello

This will create a directory called hello containing the new project.

You can also provide profile hints that will set up your project with additional files and dependencies. To see which profile hints are available, run:

lein new duct :show

Let's say we decide to use the +site and +example hints. We first remove the bare-bones project:

rm -rf hello

Then re-run the project command with the profile hints we want:

lein new duct hello +site +example

Once you've created a project you're happy with, change directory into it:

cd hello

Once inside the project, you can optionally run:

lein duct setup

This will generate files for local configuration. These files allow you to customize your local development environment, without affecting the project in version control.

Starting the system

You can now run your project. Duct uses REPL-based development, so you'll need to start a REPL:

lein repl

Once the REPL has loaded up, load up the development environment:

user=> (dev)
:loaded
dev=>

Then you can start the system with:

dev=> (go)
:duct.server.http.jetty/starting-server {:port 3000}
:initiated

By default, the web server will run on http://localhost:3000, and the example handler will be at http://localhost:3000/example.

Every time you make changes to your source code, you can refresh your app with:

dev=> (reset)
:reloading (...)
:resumed

This will restart all the services associated with your application, and reload all changed source files.

Alternatively you can have your services restart automatically on source file changes.

dev=> (auto-reset)
;; Change a Clojure or edn file
:reloading (...)
:resumed

Once you've finished development, you can halt the system:

dev=> (halt)
:stopped

Or just exit the REPL directly:

dev=> (exit)

Read the Duct guide for a more complete guide

Clone this wiki locally