Web app deployment manager
Go to file
Michael Snoyman 855ae91a99 Merge pull request #5 from solidsnack/master
Simplify use of Bash script for setup
2012-12-29 09:15:09 -08:00
cbits Place process tracker in its own process group 2012-11-19 12:11:31 +02:00
incoming/foo Host name redirects 2012-10-21 07:07:26 +02:00
Keter Correctly set UID/GID on all created folders (#4) 2012-12-27 11:52:55 +02:00
main Added --version 2012-09-29 22:44:48 +02:00
test LogFile 2012-05-17 07:15:25 +03:00
.gitignore LogFile 2012-05-17 07:15:25 +03:00
certificate.pem Initial SSL support 2012-08-09 18:12:32 +03:00
keter-config.yaml setuid support 2012-10-24 16:31:18 +02:00
keter.cabal Version bump 2012-12-27 11:53:34 +02:00
key.pem Initial SSL support 2012-08-09 18:12:32 +03:00
LICENSE Initial cabalization 2012-05-06 07:07:02 +03:00
README.md Move setting of diagnostic/error flags into script. 2012-12-28 14:27:55 +00:00
setup-keter.sh Quote variable reference (you never know :). 2012-12-28 14:29:09 +00:00
Setup.hs Initial cabalization 2012-05-06 07:07:02 +03:00

Deployment system for Yesod (and other Haskell) web apps.

Quick Start

Do get Keter up-and-running quickly on an Ubuntu system, run:

wget -O - https://raw.github.com/snoyberg/keter/master/setup-keter.sh | bash

(Note: you may need to run the above command twice, if the shell exits after apt-get but before running the rest of its instructions.) This will download and build Keter from source and get it running with a default configuration.

Setup

Instructions are for an Ubuntu system. Eventually, I hope to provide a PPA for this (please contact me if you would like to assist with this). For now, the following steps should be sufficient:

First, install PostgreSQL

sudo apt-get install postgresql

Second, build the keter binary and place it at /opt/keter/bin. To do so, you'll need to install the Haskell Platform, and can then build with cabal. This would look something like:

sudo apt-get install haskell-platform
cabal update
cabal install keter
sudo mkdir -p /opt/keter/bin
sudo cp ~/.cabal/bin/keter /opt/keter/bin

Third, create a Keter config file:

# /opt/keter/etc/keter-config.yaml
root: ..
# host: host to bind to
# port: port to listen on
# setuid: myname
# ssl:
#   host:
#   port:
#   key:
#   certificate:

Fourth, set up an Upstart job to start keter when your system boots.

# /etc/init/keter.conf
start on (net-device-up and local-filesystems and runlevel [2345])
stop on runlevel [016]
respawn

console none

exec /opt/keter/bin/keter /opt/keter/etc/keter-config.yaml

Finally, start the job for the first time:

sudo start keter

Optionally, you may wish to change the owner on the /opt/keter/incoming folder to your user account, so that you can deploy without sudoing.

sudo mkdir -p /opt/keter/incoming
sudo chown $USER /opt/keter/incoming

Bundles

An application needs to be set up as a keter bundle. This is a GZIPed tarball with a .keter filename extension and which has one special file: config/keter.yaml. A sample file is:

exec: ../dist/build/yesodweb/yesodweb
args:
    - production
host: www.yesodweb.com
ssl: false # true would use https scheme for approot

# Additional hosts your app will listen on, without affecting approot.
extra-hosts:
    - www1.yesodweb.com

# Static file hosts. Keter handles the serving for you.
static-hosts:
    - host: static.yesodweb.com
      root: ../static # relative to config file, just like the executable

# Host name redirects.
redirects:
    - from: yesodweb.com
      to: www.yesodweb.com

A sample Bash script for producing a Keter bundle is:

#!/bin/bash -ex

cabal build
strip dist/build/yesodweb/yesodweb
rm -rf static/tmp
tar czfv yesodweb.keter dist/build/yesodweb/yesodweb config static

For users of Yesod, The yesod executable provides a keter command for creating the bundle, and the scaffolded site provides a keter.yaml file.

Deploying

In order to deploy, you simply copy the keter bundle to /opt/keter/incoming. To update an app, copy in the new version. The old process will only be terminated after the new process has started answering requests. To stop an application, delete the file from incoming.