If you are deploying any app to production you want to run it as Linux daemon. In Ubuntu you can use Upstart as tool that will restart you app automatically in case of crash.
To use Upstart you need to create configuration file for your app inside the /etc/init directory.
Pick up any good name for your app (e.x. 'mywebapp') and create file /etc/init/mywebapp.conf
Let's assume that you have source code for your app in the following directory:
/root/apps/mywebapp and you can run you application within directory using lein
lein with-profile prod ring server.
Then /etc/init/mywebapp.conf content should look similar to this:
author "Team Hashobject" description "Start the mywebapp clojure on port 3000" start on (local-filesystems and net-device-up IFACE!=lo) chdir root/apps/communi.st env LEIN_ROOT=yes exec lein with-profile prod ring server
The last 3 lines are the most important:
This is just sample upstart configuration file. You can refer documentation for more features.
After you save this configuration you can start your app using
start mywebapp and stop it using
All logs for you app will be available in /var/log/upstart/mywebapp.log file.
Provided instructions should definitely work on Ubuntu 13.04. This configuration was tested on DigitalOcean with Leiningen 2 and Clojure 1.5.1.
In this post I described how to run Clojure web app in production using Leiningen and Upstart.
You can also do this by just running Java jar files using Upstart. See following article for more details.