Skip to content

Instantly share code, notes, and snippets.

@gonewest818
Created September 21, 2017 22:02
Show Gist options
  • Save gonewest818/ae5c5caf49380f81c5a2667408da6d4f to your computer and use it in GitHub Desktop.
Save gonewest818/ae5c5caf49380f81c5a2667408da6d4f to your computer and use it in GitHub Desktop.
tools.nrepl on alpine linux
Last login: Wed Sep 20 16:13:27 on ttys002
Neils-MacBook-Pro:~ neilo$ docker run -it --rm openjdk:8-alpine
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.2-146-g59aa697c0b [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.2-125-g93038b573e [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
OK: 8441 distinct packages available
/ # apk add curl bash
(1/8) Installing ncurses-terminfo-base (6.0-r8)
(2/8) Installing ncurses-terminfo (6.0-r8)
(3/8) Installing ncurses-libs (6.0-r8)
(4/8) Installing readline (6.3.008-r5)
(5/8) Installing bash (4.3.48-r1)
Executing bash-4.3.48-r1.post-install
(6/8) Installing libssh2 (1.8.0-r1)
(7/8) Installing libcurl (7.55.0-r0)
(8/8) Installing curl (7.55.0-r0)
Executing busybox-1.26.2-r5.trigger
OK: 108 MiB in 59 packages
/ # cd /usr/local/bin
/usr/local/bin # curl -O https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12871 100 12871 0 0 12871 0 0:00:01 --:--:-- 0:00:01 330k
/usr/local/bin # chmod +x lein
/usr/local/bin # cd /root
~ # lein new default foo
WARNING: You're currently running as root; probably by accident.
Press control-C to abort or Enter to continue as root.
Set LEIN_ROOT to disable this warning.
Downloading Leiningen to /root/.lein/self-installs/leiningen-2.7.1-standalone.jar now...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 618 0 618 0 0 618 0 --:--:-- --:--:-- --:--:-- 2231
100 14.6M 100 14.6M 0 0 3576 0 1:11:38 1:11:37 0:00:01 7729k
Generating a project called foo based on the 'default' template.
The default template is intended for library projects, not applications.
To see other templates (app, plugin, etc), try `lein help new`.
~ # export LEIN_ROOT=1
~ # cd foo
~/foo # cat > project.clj <<END
> (defproject foo "0.1.0-SNAPSHOT"
> :description "FIXME: write description"
> :url "http://example.com/FIXME"
> :license {:name "Eclipse Public License"
> :url "http://www.eclipse.org/legal/epl-v10.html"}
> :dependencies [[org.clojure/clojure "1.8.0"]
> [org.clojure/tools.nrepl "0.2.13"]])
> END
~/foo # lein repl
Retrieving org/clojure/clojure/1.8.0/clojure-1.8.0.pom from central
Retrieving org/sonatype/oss/oss-parent/7/oss-parent-7.pom from central
Retrieving org/clojure/tools.nrepl/0.2.13/tools.nrepl-0.2.13.pom from central
Retrieving org/clojure/pom.contrib/0.2.2/pom.contrib-0.2.2.pom from central
Retrieving org/clojure/clojure/1.2.0/clojure-1.2.0.pom from central
Retrieving clojure-complete/clojure-complete/0.2.4/clojure-complete-0.2.4.pom from clojars
Retrieving org/clojure/tools.nrepl/0.2.13/tools.nrepl-0.2.13.jar from central
Retrieving org/clojure/clojure/1.8.0/clojure-1.8.0.jar from central
Retrieving clojure-complete/clojure-complete/0.2.4/clojure-complete-0.2.4.jar from clojars
nREPL server started on port 35859 on host 127.0.0.1 - nrepl://127.0.0.1:35859
REPL-y 0.3.7, nREPL 0.2.13
Clojure 1.8.0
OpenJDK 64-Bit Server VM 1.8.0_131-b11
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (use 'clojure.tools.nrepl.server)
nil
user=> (start-server :port 7000)
SocketException Protocol family unavailable java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
user=> (start-server :port 7000 :bind "0.0.0.0")
#clojure.tools.nrepl.server.Server{:server-socket #object[java.net.ServerSocket 0x32139298 "ServerSocket[addr=/0.0.0.0,localport=7000]"], :port 7000, :open-transports #object[clojure.lang.Atom 0x150d6520 {:status :ready, :val #{}}], :transport #object[clojure.tools.nrepl.transport$bencode 0x2cbe31cc "clojure.tools.nrepl.transport$bencode@2cbe31cc"], :greeting nil, :handler #object[clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__424 0x620c07a7 "clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__424@620c07a7"], :ss #object[java.net.ServerSocket 0x32139298 "ServerSocket[addr=/0.0.0.0,localport=7000]"]}
user=>
user=>
user=>
user=> (import '(java.net ServerSocket InetSocketAddress))
java.net.InetSocketAddress
user=> (doto (ServerSocket.) (.setReuseAddress true) (.bind (InetSocketAddress. "0.0.0.0" 8000)))
#object[java.net.ServerSocket 0x7b910247 "ServerSocket[addr=/0.0.0.0,localport=8000]"]
user=> (doto (ServerSocket.) (.setReuseAddress true) (.bind (InetSocketAddress. "::" 9000)))
SocketException Protocol family unavailable java.net.PlainSocketImpl.socketBind (PlainSocketImpl.java:-2)
user=> Bye for now!
~/foo # exit
Neils-MacBook-Pro:~ neilo$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment