README.org
June 7, 2017 · View on GitHub
- boot-runit
A boot task that will provision your Clojure program with the [[http://smarden.org/runit/][runit]] supervisor, typically on a production server.
If you’ve never used runit before, you may want to refer to Kevin Chard’s excellent [[http://kchard.github.io/runit-quickstart/][quickstart]]. I have curated some more links in a blog [[http://danielsz.github.io/2014/12/06/lein-runit/][post]]. Once you understand how things work, you may want to come back and use boot-runit to automate deployment of Clojure programs.
** Installation
In build.boot:
#+BEGIN_SRC clojure
(set-env! :dependencies ‘[[danielsz/boot-runit "X.X.X"]])
(require '[danielsz.boot-runit :refer [runit]])
#+END_SRC
Where the current version is:
[[http://clojars.org/danielsz/boot-runit/latest-version.svg]]
** Usage
First, have an uberjar task ready: #+BEGIN_SRC clojure (deftask build "Builds an uberjar of this project that can be run with java -jar" [] (comp (aot :namespace '#{my.app}) (pom :project 'my-app :version "1.0.0") (uber) (jar :main 'my.app))) #+END_SRC
Now you can deploy it with runit:
#+BEGIN_SRC clojure (deftask prod [] (comp (build) (runit :env {:http-port 8023 :redis-instance "127.0.0.1"}))) #+END_SRC
Environment variables are passed as a map, and are compatible with the [[https://github.com/weavejester/environ][environ]] library. During development, you may find [[https://github.com/danielsz/boot-environ][boot-environ]] handy.
After running boot prod, you will have a shell script in the target directory.
#+BEGIN_SRC sh sh commit.sh #+END_SRC
The shell script will move everything into place with the right permissions.
** Functionality
Type on the command line:
#+BEGIN_SRC shell boot runit -h #+END_SRC
Of particular interest is the ulimit option that will tune the process in which your application is launched. You pass in the arguments to the ulimit option as you would for the ulimit command, for example -n 10000, which would set the soft limit for opening files to 10000.
The out-of-memory option will result in a self-restarting application upon encountering out of memory errors.
** License
Copyright © 2014 Daniel Szmulewicz
Distributed under the Eclipse Public License.