Commit cedc63bf authored by ROUBY Pierre-Antoine's avatar ROUBY Pierre-Antoine
Browse files

guix-kernel: Get command from 'socket-control'.

* guix-jupyter-kernel.scm (socket-shell): Set options ZMQ_RCVTIMEO to 50.
  (socket-control): Set options ZMQ_RCVTIMEO to 50.
* guix-jupyter-container.scm (shutdown): Modify 'quit' to 'exit'.
parent c0062f50
......@@ -331,8 +331,7 @@
(define (shutdown socket uuid header- parent-header
metadata content parts kernels count)
(zmq-close-socket socket-shell)
(zmq-destroy-context context)
(quit))
(exit #t))
;;
;; Dispatch route.
......
......@@ -115,6 +115,9 @@
socket-iopub
socket-stdin))
(zmq-set-socket-option socket-shell ZMQ_RCVTIMEO 50)
(zmq-set-socket-option socket-control ZMQ_RCVTIMEO 50)
;; Bind sockets to addressess.
(for-each zmq-bind-socket sockets adresses)
......@@ -227,7 +230,18 @@
(heartbeat-handler))
(define (general-handler socket containers count)
(let ((parts (zmq-get-msg-parts socket)))
;; FIXME Use 'zmq_poll'.
(define (waiting-data socket next)
(catch 'zmq-error
(λ _
(zmq-get-msg-parts socket))
(λ stuff
(cond
((equal? EAGAIN (cadr stuff))
(waiting-data next socket))
(else #f)))))
(let ((parts (waiting-data socket socket-control)))
(match parts
((wire-uuid wire-delimiter wire-singature wire-header
wire-parent-header wire-metadata wire-content)
......@@ -317,8 +331,7 @@
(define (shutdown socket uuid header- parent-header
metadata content parts containers
count)
(display "Shutdown kernel !\n")
(kill-containers containers)
(kill-containers containers parts)
(atexit)
(exit #t))
......@@ -344,38 +357,32 @@
;; Process exit and signals handler.
;;
(define (kill-containers containers)
(display "Kill container... ")
(define (kill-containers containers parts)
(display "\nKill container ")
(let ((list (vlist->list containers)))
(define (loop container)
(define (loop list)
(cond
((null? container)
(begin
(zmq-destroy-context container-context)
(display "Done.\n")
#t))
((null? list) #t)
(else
(let* ((container (car container))
(let* ((container (car list))
(name (car container))
(pid (assoc-ref container "pid")))
(kill pid SIGTERM)
(waitpid pid)
(zmq-close-socket (assoc-ref (assoc-ref container "sockets")
"shell"))
(zmq-close-socket (assoc-ref (assoc-ref container "sockets")
"shell"))
(loop (cdr container))))))
(loop list)))
(pid (assoc-ref container "pid"))
(sock (assoc-ref container "socket")))
(send-to-container containers sock name parts)
(zmq-close-socket sock)
(display ".")
(loop (cdr list))))))
(loop list)
(display " Done.\n")))
(define (atexit)
(display "Close connections... ")
(for-each zmq-close-socket sockets)
(zmq-destroy-context context)
(display "Done.\n"))
(exit #t))
(define (sig-exit-handler signum)
(atexit)
(quit))
(exit signum))
(sigaction SIGTERM sig-exit-handler)
(sigaction SIGINT sig-exit-handler)
......
Supports Markdown
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