Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lein run vs lein trampoline run vs uberjar

What is the difference between lein run, lein trampoline run and deploying a clojure app as uberjar? Is there any performance difference?

If I do a lein run/lein trampoline run I can just ssh into the server and pull my changes from git, without needing to restart the app, the same is not true for uberjar. In case of uberjars, for every change I need to build and deploy the app.

Thanks in advance.

like image 808
Chin365 Avatar asked Feb 24 '16 07:02

Chin365


1 Answers

All three of them will by default not handle your code changes in real time.

  • lein run: executes the -main function of the targeted or default namespace. Lein runs through out the full execution of that main methods so if your main function creates a web servers, then the leiningen process also stays up the whole time.
  • lein trampoline: executes the -main function as a separate process, so that the main leiningen process can exit and therefore you only have one process running
  • lein uberjar: creates a standalone jar file, so that any other user does not need to have lein installed to run your code. (or any of the source files). To run the jar, you execute java -jar myjarname.jar which contains all the source and all the dependencies.

If you are working with ring, then lein-ring has a development mode that can be started this way:

   lein ring server

which will indeed to code reloading for you.

EDIT: which one to use in production ?

Assuming here that *production* means delivering a bundled version of your code to a user

Creating a jar with lein uberjar and make your final product independent of the build tool is usually the preferred way.

like image 122
Nicolas Modrzyk Avatar answered Sep 22 '22 15:09

Nicolas Modrzyk