Commit 7da97367 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

Use <kernel> records to represent proxies.

* guix-jupyter-kernel.scm (<proxy>): Remove.
(register-proxy): Add docstring.
(new-container-connect): Return a <kernel> object.
(reply-execute-request, kill-containers): Adjust accordingly.
parent 30004d60
......@@ -19,7 +19,6 @@
(use-modules (json)
(srfi srfi-1)
(srfi srfi-9)
(srfi srfi-11)
(srfi srfi-13)
(srfi srfi-19)
......@@ -43,14 +42,6 @@
(time-second (current-time time-utc)))))
;; Kernel proxy running in a container.
(define-record-type <proxy>
(proxy pid socket start)
(pid proxy-pid) ;integer
(socket proxy-socket) ;zmq socket
(start proxy-start-time)) ;integer
;; Container tools.
......@@ -62,6 +53,8 @@
(+ (string-rindex (car (command-line)) #\/) 1)))
(define (register-proxy vhash name proxy)
"Register PROXY, a kernel object for a process running in a container that
acts as a proxy to an actual kernel."
(vhash-cons name proxy vhash))
(define (proxy-by-name vhash name)
......@@ -135,12 +128,12 @@
(container (new-container-connect env-name id))
(new (register-proxy containers env-name
(relay-message (proxy-socket container) kernel
(relay-message (kernel-shell container) kernel
(string->utf8 env-name)
(values new (+ count 1))))
((? proxy? proxy)
(relay-message (proxy-socket proxy) kernel
((? kernel? proxy)
(relay-message (kernel-shell proxy) kernel
(string->utf8 env-name)
(values containers (+ count 1))))))
......@@ -149,7 +142,7 @@
(let* ((list (string-split magic #\ ))
(env-name (list-ref list 2))
(proxy (proxy-by-name containers env-name)))
(relay-message (proxy-socket proxy) kernel
(relay-message (kernel-shell proxy) kernel
(string->utf8 env-name)
(values containers (+ count 1))))
......@@ -159,7 +152,7 @@
(delete-magic code)
(relay-message (proxy-socket
(relay-message (kernel-shell
(proxy-by-name containers "default"))
kernel (string->utf8 "default")
......@@ -202,11 +195,11 @@ MESSAGE."
((name . proxy)
(format (current-error-port)
"terminating proxy ~s (PID ~s)...~%"
name (proxy-pid proxy))
(relay-message (proxy-socket proxy) kernel
name (kernel-pid proxy))
(relay-message (kernel-shell proxy) kernel
(string->utf8 name) message)
(zmq-close-socket (proxy-socket proxy))
(false-if-exception (kill (proxy-pid proxy) SIGTERM))))
(zmq-close-socket (kernel-shell proxy))
(false-if-exception (kill (kernel-pid proxy) SIGTERM))))
......@@ -214,7 +207,7 @@ MESSAGE."
(define (new-container-connect name pid)
"Return a proxy object for process PID."
"Return a kernel object for process PID."
(let* ((ipc-dir (string-append "/tmp/guix-kernel/ipc/" name "-"
(number->string session-id) "/"))
(container-addr (string-append "ipc://" ipc-dir))
......@@ -228,7 +221,9 @@ MESSAGE."
(zmq-bind-socket container-socket container-addr-sock)
(display "+")
(proxy pid container-socket (current-time time-utc)))))
(kernel name pid
#:shell container-socket
#:iosub container-socket))))
(define %network-file-systems
;; The list of <file-system> objects corresponding to bind-mounts required
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment