Skip to content

A boot task for runit, an init scheme with service supervision

Notifications You must be signed in to change notification settings

danielsz/boot-runit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 

Repository files navigation

boot-runit

A boot task that will provision your Clojure program with the runit supervisor, typically on a production server. If you’ve never used runit before, you may want to refer to Kevin Chard’s excellent quickstart. I have curated some more links in a blog 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:

(set-env! :dependencies ‘[[danielsz/boot-runit "X.X.X"]])
(require '[danielsz.boot-runit :refer [runit]])

Where the current version is:

http://clojars.org/danielsz/boot-runit/latest-version.svg

Usage

First, have an uberjar task ready:

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

Now you can deploy it with runit:

(deftask prod
  []
  (comp
   (build)
   (runit :env {:http-port 8023
                :redis-instance "127.0.0.1"})))

Environment variables are passed as a map, and are compatible with the environ library. During development, you may find boot-environ handy.

After running boot prod, you will have a shell script in the target directory.

$ cd target
$ sh commit.sh

The shell script will move everything into place with the right permissions.

Functionality

Type on the command line:

boot runit -h

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.

About

A boot task for runit, an init scheme with service supervision

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published