Skip to content

Commit

Permalink
Merge pull request #5 from ojung/choose-free-port
Browse files Browse the repository at this point in the history
Choose free port
  • Loading branch information
oskar committed Sep 23, 2015
2 parents dc772e5 + 589c27d commit 41a4567
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
3 changes: 2 additions & 1 deletion mbeanz/mbeanz
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import json
import requests
import subprocess32

api_url = 'http://localhost:7999'
port = [line.rstrip('\n') for line in open('/var/tmp/mbeanz.port')][0]
api_url = 'http://localhost:' + port

class colors:
OKGREEN = '\033[92m'
Expand Down
16 changes: 0 additions & 16 deletions mbeanz/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,2 @@
enum34==1.0.4
futures==3.0.3
greenlet==0.4.7
httpie==0.9.2
msgpack-python==0.4.6
neovim==0.0.37
pep8==1.5.6
powerline-status==2.1
pyflakes==0.8.1
Pygments==2.0.2
pyzmq==14.1.1
requests==2.7.0
speedtest-cli==0.2.5
subprocess32==3.2.6
trollius==2.0
vboxapi==1.0
virtualenv==13.1.2
wheel==0.24.0
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[org.clojure/core.match "0.3.0-alpha4"]
[compojure "1.3.4"]
[ring.middleware.logger "0.5.0"]
[http-kit "2.0.0"]
[http-kit "2.1.17"]
[ring/ring-mock "0.3.0"]
[ring/ring-defaults "0.1.2"]
[ring/ring-json "0.4.0"]
Expand Down
9 changes: 7 additions & 2 deletions src/mbeanz/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
[environ.core :refer [env]]
[clojure.java.jmx :as jmx])
(:use [org.httpkit.server :only [run-server]]
[clj-stacktrace.core :only [parse-exception]])
[clj-stacktrace.core :only [parse-exception]]
[clojure.java.io :only [writer]])
(:import java.lang.management.ManagementFactory))

(defonce server (atom nil))

(def object-pattern (delay (or (env :mbeanz-object-pattern) "*:*")))

(def jmx-remote-host (delay (or (env :mbeanz-jmx-remote-host) "localhost")))
Expand Down Expand Up @@ -62,4 +65,6 @@
(wrap-defaults api-defaults)))

(defn -main [& args]
(run-server app {:port 7999}))
(reset! server (run-server app {:port 0}))
(with-open [my-writer (writer "/var/tmp/mbeanz.port")]
(.write my-writer (str (:local-port (meta @server))))))

0 comments on commit 41a4567

Please sign in to comment.