How to reduce reload time when deploying clojure web service?

I am using Linux / upstart to get my jar up and running. I do it this way:

  • lein uberjar produces myapp.jar
  • copy myapp.jar with scp to dedicated server
  • ssh to dedicated server
  • stop myapp.jar
  • copy the jar to the target directory (hence the upstart can find it)
  • run myapp.jar

There are several problems:

  • It is difficult to do steps 1, 2, 3 and 6. I think it is possible to do this in a script, but I am not sure if it is a good idea to replace myapp.jar before stopping myapp. Is it safe to modify the jar file while it is running?
  • The delay between steps 5 and 7 is about 10 seconds. Is it possible to update myapp.jar right away? And even more interesting: is it possible to update in place: for example, I opened connections and I would like to save them.
  • Can it be done like Erlang does? Expand and if it fails, it downloads the previous version.
+3


source to share





All Articles