Skip to content

Commit

Permalink
Added initial health-check command.
Browse files Browse the repository at this point in the history
Addresses initial part of #47.
  • Loading branch information
oubiwann committed Feb 21, 2021
1 parent fb5c798 commit ffd387b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 6 additions & 1 deletion priv/help/repl-extempore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ Built-in functions:

(call body) -- make an explicitly blocking call to Extempore, with 'body' being
a valid Extempore expression
(check-xt) -- check on the status of Extempore (no response indicates a health
problem, possibly requiring a restart of the 'extempore' binary)
(eom) -- alias for '(term)'
(exit) -- alias for '(quit)'
(h) -- alias for '(help)'
(help) -- display this information
(quit) -- quit the Extempore REPL and return to the LFE REPL
(run file) -- load the code in the given file and run in Extempore
(v) -- alias for '(version')
(term) -- send message-terminating character sequence to force Extempore
end-of-message (useful when troubleshooting)
(v) -- alias for '(version)'
(version) -- display all the version info for undertone

Extempore support:
Expand Down
5 changes: 5 additions & 0 deletions src/undertone/repl/extempore.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
(case (mref sexp 'tokens)
('() 'empty)
(`("call" . ,_) (xt-blocking-eval sexp))
('("check-xt") 'check-xt)
('("eom") 'term)
('("exit") 'quit)
('("h") 'help)
Expand Down Expand Up @@ -53,6 +54,7 @@
(defun print (result)
(case result
('() 'ok)
('check-xt (check-extempore))
('empty 'ok)
('help (help))
('quit 'ok)
Expand Down Expand Up @@ -80,6 +82,9 @@
;;;::=- shell functions -=::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;::=--------------------=::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun check-extempore ()
(xt.msg:async "#(health ok)"))

(defun help ()
(lfe_io:format "~s" `(,(binary_to_list
(undertone.sysconfig:read-priv
Expand Down
9 changes: 6 additions & 3 deletions src/xt/msg.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
(defun rcv-delim () #b(0))

(defun async (str)
(log-debug "Casting ~s ..." `(,str))
(log-debug "Casting: ~s" `(,str))
(tcp-client:cast-msg (payload str)))

(defun payload (str)
(binary:list_to_bin (++ str (xmit-delim))))

(defun sync (str)
(log-debug "Calling ~s ..." `(,str))
(log-debug "Calling: ~s" `(,str))
(tcp-client:call-msg (payload str)))

;;;;;::=------------------------------------=::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -36,7 +36,10 @@
("Welcome to extempore!" (progn
(timer:sleep 500)
(undertone.sysconfig:render-banner)))
(_ 'ok)))
("#(health ok)" (log-notice "Extempore TCP server connection healthy"))
(_ (progn
(log-debug "No special packet handling for parsed value")
'ok))))

(defun parse-response
((packet `#(,reporter-mod ,reporter-func))
Expand Down

0 comments on commit ffd387b

Please sign in to comment.