It depends on whether you want your service to run straight from your project directory, or whether you want to go through the intermediate step of creating and installing a build artifact.
Certainly during development it's more convenient to use lein run
from your project directory. For the sake of repeatability, I'd recommend using the second approach for production systems.
The general approach would be to use the lein uberjar
task to create a stand-alone JAR file. From there, it's pretty straightforward (though somewhat tedious) to create a script you can stick in /etc/init.d
to run the JAR file, either directly via java
or using jsvc
.
It looks like there's a Leiningen plugin (lein-init-script) to automate the process of generating the service script, though I don't have any experience with it. You'll probably want to check that out.