Deploying a Web Service with Crane
Deploying a web service is pretty simple with Crane. First you add Crane's leiningen plugin with the crane dependency in your project.clj.
[crane "1.0-SNAPSHOT"]Then you add a deploy.clj file into the src directory. The config files are formatted as Clojure maps. In Crane, no-arg functions can be called in your deploy.clj as targets.
lein crane webThe deploy.clj file can access anything in your project classpath, including Crane. Crane is used as a normal library.
Web must be a target in the deploy.clj:
(defn web In this example, the webserver is deployed using Crane's bootstrap capabilities.
(bootstrap :webconfig :webcreds)))
Bootstrap in Crane
Crane's three basic phases are install, push, and run. Crane mostly builds up vectors of strings (of commands to run or files to sync) in addition to supplying basic configuration attributes such as groups, project roots, etc. "Anywhere that you could supply a string, you can supply a vector of strings and keywords, and the keyworkds will be replaced with their corresponding values from the config map," said Cross.
The install phase will install packages on your linux distro, and you can supply a vector of install commands as strings. The push phase syncs both local and remote files. Lastly, the run phase runs the commands and starts your webserver, worker processes, databases, or other service.
For more info on Crane, read a recent blog by Cross.