0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-02 10:45:41 -05:00
penpot/backend/src/app/srepl.clj

55 lines
1.1 KiB
Clojure
Raw Normal View History

;; This Source Code Form is subject to the terms of the Mozilla Public
;; License, v. 2.0. If a copy of the MPL was not distributed with this
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
;;
2021-04-10 09:43:04 +02:00
;; Copyright (c) UXBOX Labs SL
(ns app.srepl
"Server Repl."
(:require
[app.common.spec :as us]
[app.srepl.main]
[clojure.core.server :as ccs]
[clojure.main :as cm]
[clojure.spec.alpha :as s]
[integrant.core :as ig]))
(defn- repl-init
[]
(ccs/repl-init)
(in-ns 'app.srepl.main))
(defn repl
[]
(cm/repl
:init repl-init
:read ccs/repl-read))
;; --- State initialization
(s/def ::name ::us/not-empty-string)
(s/def ::port int?)
(s/def ::host ::us/not-empty-string)
(defmethod ig/pre-init-spec ::server
[_]
(s/keys :opt-un [::port ::host ::name]))
(defmethod ig/prep-key ::server
[_ cfg]
2021-01-27 17:31:17 +01:00
(merge {:name "main"} cfg))
(defmethod ig/init-key ::server
[_ {:keys [port host name] :as cfg}]
(ccs/start-server {:address host
:port port
:name name
:accept 'app.srepl/repl})
cfg)
(defmethod ig/halt-key! ::server
[_ cfg]
(ccs/stop-server (:name cfg)))