Getting Started

James Reeves edited this page Jun 15, 2017 · 11 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)

Then you can start the system with:

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

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

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

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

dev=> (halt)

Or just exit the REPL directly:

dev=> (exit)
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.