Fork me on GitHub

hi guys and gals! total Clojure noob here. i was reading the Brave Clojure book and started using Leiningen. i'm on Windows so used the installer on the Leiningen site, created my project, but getting an error running it: No :main namespace specified in project.clj. my project.clj was created from the lein new app ... command.


nevermind, figured it out, thanks anyway! 🦆


@weller: what was the problem?


@weller: another thing to keep in mind, when you run lein repl you'll only have things in the namespace as if you were writing code in the body of whatever the :main value points to rather than the whole project (this makes sense after you know the answer and then think about it but can be elusive when you're learning about a bunch of stuff at the same time). I ran into a similar issue and had a comically long workflow for restarting my repl for a bit.


hi, port for production jetty server is 80? which port i need to specify in main function?


normally if you want port 80, we proxy through nginx


you can use any port, the risk with running it on port 80 is that you expose yourself to a world of hurt because the process has to be run as root for that to be possible.


it is a common practice when developing jvm-based apps to not use port 80, and proxy through nginx


@roberto: yes, when i`m trying to deploy app to heroku with port 80, they stoped with error "permission denied". That means i need to use 8080? Because when i`m not set port in main func. that run jetty server - server stops with error


you can use any port in heroku


it will know to route it to your port


this means i can set 3000 port, deploy app, and when i will send the request from browser without specified port, thats will be good?


you must bind to the port defined by $PORT on Heroku


you can bind to other ports (above 1028 because those require sudo), but they will not be hooked into the router


@codefinger: i can set 3000 port in main func?


yes, but you need to do what @codefinger said, you need to set the $PORT variable in Heroku


in heroku in key field i set $PORT and in value field i set 3000 - correct?


thank`s for all, i will try yours suggestions


you can't set $PORT yourself. Heroku assigns it for you. so you have to bind to a port dynamically in the app. For example


i was deploy the app with port 5000 in main func, set env variable in heroku to 5000, server was run but when i send request from browser, its give me error in log file, like this - Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch


you can't set PORT yourself. You have to use the one Heroku assigns you


the R10 means nothing bound to the port that Heroku assigned, probably because you are binding to 5000


@codefinger: ok, tell me how to write my main func: (defn -main [] (ring/run-jetty #'app {:port 5000}))


@agi_underground: did you look at the example I linked to above?


you can use environ and do (env :port) or just (System/getenv "PORT")


yes, ok if i connect environ and make like in example, i don`t need to configure manualy in heroku right?


i will write about it later, work it or not


right, you won't ever need (or be able to) configure the port in Heroku


with environ all works great! thanx @codefinger