3
votes

How can I generate a standalone ring uberjar that listens to a given port ?

When developing I launch my app with the following leiningen/ring command, in which I can specify the port :

lein with-profile dev ring server-headless 9696

Now I want to deploy it, so I ran :

lein with-profile prod ring uberjar 9696

But I got an error :

Error encountered performing task 'ring' with profile(s): 'prod'
clojure.lang.ArityException: Wrong number of args (2) passed to: uberjar/uberjar

So I added a :portin my project.clj :

:ring    {:handler img-cli.handler/handler
          :init    img-cli.handler/init
          :destroy img-cli.handler/destroy
          :port    9696}

lein with-profile prod ring uberjar
java -jar my-jar.jar

But then I see in the logs : Started server on port 3000

How do I generate an uberjar with the port that I want ?

Note : just in case, I'm using compojure.

1
It works for me, did you compile the jar after applying the changes in the project.clj? - Paulo Bu
@PauloBu Ah it turns out I had to use lein with-profile +prod ring uberjar 9696 (notice the +) - nha

1 Answers

1
votes

It turns out that my use of the profile was problematic.

A closer looks at the profile documentation yields :

To activate a profile in addition to the defaults, prepend it with a +:

$ lein with-profile +server run

Therefore I had to use lein with-profile +prod ring uberjar 9696 (notice the +).