Skip to content

Commit

Permalink
Move bluegenes.server to bluegenes.core
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkh committed Jan 16, 2018
1 parent cc8f0f6 commit 97f2f70
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: java -cp target/bluegenes.jar clojure.main -m bluegenes.server
web: java -cp target/bluegenes.jar clojure.main -m bluegenes.core
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
:optimizations :none}}}}


:main bluegenes.server
:main bluegenes.core

:uberjar-name "bluegenes.jar"

Expand Down
35 changes: 34 additions & 1 deletion src/clj/bluegenes/core.clj
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
(ns bluegenes.core)
(ns bluegenes.core
(:require [bluegenes.handler :refer [handler]]
[config.core :refer [env]]
[ring.adapter.jetty :refer [run-jetty]]
[taoensso.timbre :as timbre :refer [infof errorf]]
[mount.core :as mount]
; Including this namespace establishes the database connection when (mount/start) is called:
[bluegenes.mounts :as mounts]
[bluegenes.migrations :as migrations])
(:gen-class))

(defn ->int
"Force a value to a number (environment variables are read as strings)"
[n]
(cond
(string? n) (read-string n)
(int? n) n
:else n))

(defn -main
"Start the BlueGenes server. This is the main entry point for the application"
[& args]
; Parse the port from the configuration file, environment variables, or default to 5000
; "PORT" is often the default value for app serving platforms such as Heroku and Dokku
(let [port (->int (or (:server-port env) (:port env) 5000))]
(timbre/set-level! :info) ; Enable Logging
(try
(do
(mount/start) ; Mount our database connection
(migrations/migrate)) ; Apply any database migrations that haven't been applied
(catch Exception e (errorf "Unable to connect to database: %s" (.getMessage e))))
; Start the Jetty server by passing in the URL routes defined in 'handler'
(run-jetty handler {:port port :join? false})
(infof "Bluegenes server started on port: %s" port)))
34 changes: 0 additions & 34 deletions src/clj/bluegenes/server.clj

This file was deleted.

0 comments on commit 97f2f70

Please sign in to comment.