Skip to content

Instantly share code, notes, and snippets.

@elisehuard
Last active December 5, 2017 16:04
Show Gist options
  • Save elisehuard/f7f488693e379bca66669c613d0bddb3 to your computer and use it in GitHub Desktop.
Save elisehuard/f7f488693e379bca66669c613d0bddb3 to your computer and use it in GitHub Desktop.
gorilla repl boot task
(def gorilla-version "0.4.0") ;; adapt this as needed
(set-env!
:resource-paths #{"src" "resources"}
:dependencies '[[gorilla-repl "0.4.0"]]) ;; version!
(task-options!
pom {:project 'restaurant
:version "0.1.0-SNAPSHOT"}
jar {:manifest {"Foo" "bar"}})
(ns boot.user
(:require [gorilla-repl.core :refer [run-gorilla-server]]
[boot.core :as core]
[boot.pod :as pod]))
(def server-deps
'[[gorilla-repl "0.4.0"]]) ;; version!
(deftask gorilla-server
"start a gorilla repl"
[p port PORT int "gorilla repl port"
n nrepl-port PORT int "nrepl port"
i ip IP str "ip address"]
(let [port (or port 9000)
_ (println "port" (type port) port)
ip (or ip "127.0.0.1")
_ (println "ip" (type ip) ip)
nrepl-port (or nrepl-port (+ 30000 (rand-int 10000)))
project-name ""
gorilla-options {}
deps server-deps
worker (pod/make-pod (update-in (core/get-env) [:dependencies]
into deps))
start (delay
(pod/with-eval-in worker
(require '[gorilla-repl.core :refer [run-gorilla-server]]
'[boot.util :as boot])
(def server
(run-gorilla-server {:port ~port
:ip ~ip
:nrepl-port ~nrepl-port
:version ~gorilla-version
:project ~project-name
:gorilla-options ~gorilla-options}))
(boot/info "started on http://%s:%d\n"
~ip
~port)))]
(core/cleanup
(pod/with-eval-in worker
(do (reset! @server nil)
(boot/info "stopping gorilla repl"))))
(core/with-pre-wrap fileset
@start
(assoc fileset :gorilla (pod/with-eval-in worker server)))))
(deftask gorilla
[]
(comp (gorilla-server) (wait)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment