Skip to content

Commit

Permalink
Configure host with --host (#74)
Browse files Browse the repository at this point in the history
* Configure host with --host

e.g. using --host 127.0.0.1 restricts incoming connections to those
from localhost

* fix

* nix variables, use defaults
  • Loading branch information
notmgsk authored and stylewarning committed Apr 18, 2019
1 parent 6407193 commit b985236
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions app/src/entry-point.lisp
Expand Up @@ -34,9 +34,16 @@
:optional t
:documentation "start a QVM server")

(("host")
:type string
:optional t
:initial-value "0.0.0.0"
:documentation "host on which to start the QVM server")

(("port" #\p)
:type integer
:optional t
:initial-value 5000
:documentation "port to start the QVM server on")

(("qubits" #\q)
Expand Down Expand Up @@ -190,18 +197,13 @@ Copyright (c) 2016-2019 Rigetti Computing.~2%")
(or *num-workers* (max 1 (qvm:count-logical-cores))))
nil)

(defparameter *host-address* "0.0.0.0")
(defparameter *default-host-port* 5000)

(defun start-server-app (port)
(defun start-server-app (host port)
(check-type port (or null (integer 0 65535))
"The port must be between 0 and 65535.")
(when (null port)
(setf port *default-host-port*))
(format-log "Starting server on port ~D." port)
(unless (null *qubit-limit*)
(format-log "Server is limited to ~D qubit~:P." *qubit-limit*))
(start-server port)
(start-server host port)
;; TODO? Make this join the thread, instead of spinning in a loop.
(loop (sleep 1)))

Expand Down Expand Up @@ -332,6 +334,7 @@ Copyright (c) 2016-2019 Rigetti Computing.~2%")
help
memory-limit
server
host
port
#-forest-sdk swank-port
num-workers
Expand Down Expand Up @@ -493,7 +496,7 @@ Version ~A is available from downloads.rigetti.com/qcs-sdk/forest-sdk.dmg~%"

(format-log "Created persistent memory for ~D qubits" qubits))
;; Start the server
(start-server-app port))
(start-server-app host port))

;; Batch mode.
(t
Expand Down Expand Up @@ -614,7 +617,7 @@ Version ~A is available from downloads.rigetti.com/qcs-sdk/forest-sdk.dmg~%"
(defun asdf-entry-point ()
(%main (list* "qvm-app" (uiop:command-line-arguments))))

(defun start-server (port)
(defun start-server (host port)
#+forest-sdk
(setq tbnl:*log-lisp-backtraces-p* nil
tbnl:*log-lisp-errors-p* nil)
Expand All @@ -625,7 +628,7 @@ Version ~A is available from downloads.rigetti.com/qcs-sdk/forest-sdk.dmg~%"
tbnl:*catch-errors-p* (not *debug*))
(setq *app* (make-instance
'vhost
:address *host-address*
:address host
:port port
:taskmaster (make-instance 'tbnl:one-thread-per-connection-taskmaster)))
(when (null (dispatch-table *app*))
Expand Down

0 comments on commit b985236

Please sign in to comment.