Back
start-server (clj)
(source)function
(start-server opts)
Start a socket server given the specified opts:
:address Host or address, string, defaults to loopback address
:port Port, integer, required
:name Name, required
:accept Namespaced symbol of the accept function to invoke, required
:args Vector of args to pass to accept function
:bind-err Bind *err* to socket out stream?, defaults to true
:server-daemon Is server thread a daemon?, defaults to true
:client-daemon Are client threads daemons?, defaults to true
Returns server socket.
Examples
babashka/babashka
(ns babashka.impl.server
(:require [babashka.impl.clojure.core.server :as server]
[babashka.impl.common :as common]
[babashka.impl.socket-repl :as socket-repl]
[sci.core :as sci]))
(def start-server
(fn [& args]
(apply server/start-server (common/ctx) args)))
(def clojure-core-server-namespace
{'repl (sci/copy-var socket-repl/repl sns)
'prepl (sci/copy-var prepl sns)
'io-prepl (sci/copy-var io-prepl sns)
'start-server (sci/copy-var start-server sns)
'stop-server (sci/copy-var server/stop-server sns)})
kit-clj/kit
(ns kit.edge.utils.repl
(:require
[clojure.core.server :as socket]
[clojure.tools.logging :as log]
[integrant.core :as ig]))
(defmethod ig/init-key :repl/server
[_ {:keys [port host name] :as config}]
(try
(socket/start-server {:address host
:port port
:name name
:accept 'clojure.core.server/repl})
(log/info "REPL server started on host:" host "port:" port)
(catch Exception e
(log/error "failed to start the REPL server on host:" host "port:" port)
(throw e)))
config)
reborg/clojure-essential-reference
(require '[clojure.core.server :as server]) ; <1>
(server/start-server ; <2>
{:name "repl1" :port 8787 :accept clojure.core.server/repl})
;; #object["ServerSocket[addr=localhost/127.0.0.1,localport=8787]"]
sereno-xyz/sereno
(ns app.repl
"Server repl."
(:require
[clojure.tools.logging :as log]
[clojure.spec.alpha :as s]
[app.common.spec :as us]
[clojure.core.server :as srv]
[integrant.core :as ig]))
(defmethod ig/init-key ::server
[_ {:keys [name port host]}]
(log/infof "Starting repl server '%s'." name)
(srv/start-server
{:name name
:port port
:address host
:accept 'clojure.core.server/repl})
name)