Skip to content

Commit 2d9bdad

Browse files
committed
Add section on 'Deployment' to docs
1 parent ceb2a4f commit 2d9bdad

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

docs/index.adoc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,62 @@ used in this example for the sake of brevity.
17511751
Now that we have both a server and client, we can `(reset)` the REPL
17521752
and check the web application at: <http://localhost:3000>
17531753

1754+
=== Deployment
1755+
1756+
During development we typically run every key int the system, but when
1757+
we deploy, it's often useful to run a subset.
1758+
1759+
We can specify which keys to run with the `--keys` option. This will
1760+
run all the keys we specify, along with their *descendent* and
1761+
*dependent* keys.
1762+
1763+
NOTE: A key is _descendent_ on another if it is derived from that key
1764+
via Clojure's `derive` function. A key is _dependent_ on another if it
1765+
is linked via an Integrant ref or refset.
1766+
1767+
Duct defines a hierarchy of keys, with many descending from a small
1768+
selection of ancestor keys:
1769+
1770+
[horizontal]
1771+
`:duct/compiler` :: compile static assets
1772+
`:duct/migrator` :: migrate the database schema
1773+
`:duct/daemon` :: run daemon process such as a server
1774+
1775+
When deploying, we need to initiate all three of these lineages.
1776+
1777+
Compilation typically takes place once on the build server. In the web
1778+
application we've been building, this will compile ClojureScript into
1779+
static JavaScript.
1780+
1781+
[,shell]
1782+
----
1783+
$ duct --main --keys :duct/compiler # compiles static resources
1784+
----
1785+
1786+
Migration requires access to the database, and typically must be run
1787+
by a single machine. If two machines attempt to migrate the database
1788+
at the same time we're likely to run into conflicts. Thus, as part of
1789+
the deployment, a single machine should be designated to run the
1790+
migration.
1791+
1792+
[,shell]
1793+
----
1794+
$ duct --main --keys :duct/migrator # migrates the database
1795+
----
1796+
1797+
Finally we run the daemon processes of our application. This includes
1798+
the web server, `:duct.server.http/jetty`, which is added as part of
1799+
the web module.
1800+
1801+
[,shell]
1802+
----
1803+
$ duct --main --keys :duct/daemon # runs the application
1804+
----
1805+
1806+
Daemons may be run on multiple machines, and may be started and stopped
1807+
by the host environment at any time.
1808+
1809+
17541810
== Existing Applications
17551811

17561812
So far we have worked on the assumption that you are building a Duct

0 commit comments

Comments
 (0)