27
votes

It seems to me that the only difference between lein run and lein trampoline is that the latter quits Leiningen's JVM to save memory.

This seems always a good idea, so why is this feature not included in lein run and then get rid of lein trampoline?

1
From personal experience (and I never really verified this so I might be wrong), trampoline makes it impossible to track the process using a supervising daemon, eg supervisor.Johanna Larsson
My experience has been quite the reverse of Erik's. Using daemontools on FreeBSD, 'lein run' in the service's run script meant that 'svc -d' terminated the lein process and orphaned the child service JVM. 'lein trampoline' fixed this. Depends on the requirements of your supervisor daemon, I guess.Danny Woods

1 Answers

22
votes

lein trampoline can be used for any leiningen task, not just lein run. For example, lein trampoline test.

Essentially, lein trampoline kills the original leiningen process so that only the actual JVM that spawns for running your Clojure stuff is alive when the task starts running. This is useful for shell scripting since killing the actual JVM won't kill the leiningen process, and vice versa.