Fork me on GitHub
Mutasem Hidmi07:01:36

I am trying to run a web server using mount/defstate, but it's not working. Am I missing something here? I am calling (mount/start) in the main function.

Mutasem Hidmi07:01:42

(defn get-port []
  (Integer/parseInt (or (env :server-port) "8080")))

(defn start-server []
  (let [selected-port (get-port)]
    (println "INFO: Starting server on port: " selected-port)
    ;TODO loading the server from the mount and add dependencies that are in the mount
    (jetty/run-jetty #'app {:port selected-port :join? false})))

(mount/defstate server :start (start-server))

Jan K14:01:22

Don't call (mount/start) in the start function of your component. You should call it from the main function of the entire program to start all the components.