Overview
Comment: | Code for server etc. converted to nng but not tested |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.6584-nanomsg |
Files: | files | file ages | folders |
SHA1: |
9d2d6a97d754b3da485d29ea0bfb1326 |
User & Date: | matt on 2021-11-02 20:21:38 |
Other Links: | branch diff | manifest | tags |
Context
2021-11-03
| ||
20:56 | Incomplete converstion of dashboard (i.e wip) check-in: 7bd4d885f7 user: matt tags: v1.6584-nanomsg | |
2021-11-02
| ||
20:21 | Code for server etc. converted to nng but not tested check-in: 9d2d6a97d7 user: matt tags: v1.6584-nanomsg | |
2021-10-21
| ||
16:19 | Got crude nng transport implementation working/ check-in: 96b5fc4451 user: matt tags: v1.6584-nanomsg | |
Changes
Deleted common.scm version [4b8aa57ac0].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Modified megatest.scm from [e4c2fb81d3] to [3421381fd4].
︙ | ︙ | |||
167 168 169 170 171 172 173 | ;; (include "common_records.scm") ;; (include "key_records.scm") ;; (include "db_records.scm") (include "run_records.scm") ;; (include "test_records.scm") | | | | 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | ;; (include "common_records.scm") ;; (include "key_records.scm") ;; (include "db_records.scm") (include "run_records.scm") ;; (include "test_records.scm") ;; (include "common.scm") (include "db.scm") ;; (include "server.scm") (include "tests.scm") (include "genexample.scm") (include "tdb.scm") (include "env.scm") (include "diff-report.scm") (include "ods.scm") |
︙ | ︙ |
Modified rmtmod.scm from [d367d765b7] to [b3af46403d].
︙ | ︙ | |||
60 61 62 63 64 65 66 | directory-utils ;; http-client ;; intarweb matchable md5 message-digest | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | directory-utils ;; http-client ;; intarweb matchable md5 message-digest nng ;; nanomsg (prefix base64 base64:) (prefix sqlite3 sqlite3:) regex s11n ;; spiffy ;; spiffy-directory-listing ;; spiffy-request-vars |
︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 | (begin (servdat-host-set! *server-info* ipaddrstr) (servdat-port-set! *server-info* port) (servdat-status-set! *server-info* 'trying-port) (servdat-trynum-set! *server-info* (+ (servdat-trynum *server-info*) 1))) (set! *server-info* (make-servdat host: ipaddrstr port: port))) (let* ((rep (rmt:try-start-server ipaddrstr port))) | | | | | 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 | (begin (servdat-host-set! *server-info* ipaddrstr) (servdat-port-set! *server-info* port) (servdat-status-set! *server-info* 'trying-port) (servdat-trynum-set! *server-info* (+ (servdat-trynum *server-info*) 1))) (set! *server-info* (make-servdat host: ipaddrstr port: port))) (let* ((rep (rmt:try-start-server ipaddrstr port))) (let loop ((instr (nng-recv rep))) (let* ((data (string->sexpr instr)) (res (case data ((quit) 'quit) (else (api:process-request *dbstruct-db* data)))) (resdat (sexpr->string res))) (if (not (eq? res 'quit)) (begin (set! *db-last-access* (current-seconds)) (nng-send rep resdat) (loop (nng-recv rep))))))) (debug:print-info 0 *default-log-port* "After server, should never see this") ;; server exit stuff here (let* ((portnum (servdat-port *server-info*))) (portlogger:open-run-close portlogger:set-port portnum "released") (rmt:server-shutdown) ;; (bdat-time-to-exit-set! *bdat* #t) ;; tell on-exit to be fast as we've already cleaned up (portlogger:open-run-close portlogger:set-port port "released") ;; done in rmt:run |
︙ | ︙ | |||
1687 1688 1689 1690 1691 1692 1693 | (if (not *server-info*) (set! *server-info* (make-servdat host: ipaddrstr port: portnum))) (servdat-status-set! *server-info* 'starting) (servdat-port-set! *server-info* portnum) (if (not (servdat-rep *server-info*)) | > | > | | 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 | (if (not *server-info*) (set! *server-info* (make-servdat host: ipaddrstr port: portnum))) (servdat-status-set! *server-info* 'starting) (servdat-port-set! *server-info* portnum) (if (not (servdat-rep *server-info*)) (let ((rep (make-rep-socket))) (servdat-rep-set! *server-info* rep) (socket-set! rep 'nng/recvtimeo 2000))) (let* ((rep (servdat-rep *server-info*))) (debug:print 0 *default-log-port* "INFO: Trying to start server on " ipaddrstr ":" portnum) (handle-exceptions exn (begin (print-error-message exn) (if (< portnum 64000) (begin (debug:print 0 *default-log-port* "WARNING: attempt to start server failed. Trying again ...") (debug:print 0 *default-log-port* " message: " ((condition-property-accessor 'exn 'message) exn)) (debug:print 5 *default-log-port* "exn=" (condition->list exn)) (portlogger:open-run-close portlogger:set-failed portnum) (debug:print 0 *default-log-port* "WARNING: failed to start on portnum: " portnum ", trying next port") ;; (thread-sleep! 0.1) (rmt:try-start-server ipaddrstr (portlogger:open-run-close portlogger:find-port))) (begin (print "ERROR: Tried and tried but could not start the server, stopping at port "portnum)))) (nng-listen rep (conc "tcp://*:" portnum)) rep))))) ;;====================================================================== ;; S E R V E R U T I L I T I E S ;;====================================================================== ;;====================================================================== |
︙ | ︙ | |||
2283 2284 2285 2286 2287 2288 2289 | (set! ret #t)) (loop (read-line inp))))))) ret)) ;;start a server, returns the connection ;; (define (start-nn-server portnum ) | | > | | | > | | | | | | | | | | 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 | (set! ret #t)) (loop (read-line inp))))))) ret)) ;;start a server, returns the connection ;; (define (start-nn-server portnum ) (let ((rep (make-rep-socket))) ;; (nn-socket 'rep))) (socket-set! rep 'nng/recvtimeo 2000) (handle-exceptions exn (let ((emsg ((condition-property-accessor 'exn 'message) exn))) (print "ERROR: Failed to start server \"" emsg "\"") (exit 1)) (nng-dial #;nn-bind rep (conc "tcp://*:" portnum))) rep)) ;; open connection to server, send message, close connection ;; (define (open-send-close-nn host-port msg #!key (timeout 3) ) ;; default timeout is 3 seconds (let ((req (make-req-socket 'req)) (uri (conc "tcp://" host-port)) (res #f) ;; (contacts (alist-ref 'contact attrib)) ;; (mode (alist-ref 'mode attrib)) ) (socket-set! req 'nng/recvtimeo 2000) (handle-exceptions exn (let ((emsg ((condition-property-accessor 'exn 'message) exn))) ;; Send notification (debug:print 0 *default-log-port* "ERROR: Failed to connect / send to " uri " message was \"" emsg "\"" ) #f) (nng-dial req uri) ;; (print "Connected to the server " ) (nng-send req msg) ;; (print "Request Sent") (let* ((th1 (make-thread (lambda () (let ((resp (nng-recv req))) (nng-close! req) (set! res (if (equal? resp "ok") #t #f)))) "recv thread")) (th2 (make-thread (lambda () (thread-sleep! timeout) (thread-terminate! th1)) "timer thread"))) (thread-start! th1) (thread-start! th2) (thread-join! th1) res)))) (define (open-send-receive-nn host-port msg #!key (timeout 3) ) ;; default timeout is 3 seconds (let ((req (make-req-socket)) (uri (conc "tcp://" host-port)) (res #f) ;; (contacts (alist-ref 'contact attrib)) ;; (mode (alist-ref 'mode attrib)) ) (handle-exceptions exn (let ((emsg ((condition-property-accessor 'exn 'message) exn))) ;; Send notification (debug:print 0 *default-log-port* "ERROR: Failed to connect / send to " uri " message was \"" emsg "\", exn=" exn) #f) (nng-dial req uri) ;; (print "Connected to the server " ) (nng-send req msg) ;; (print "Request Sent") ;; receive code here ;;(print (nn-recv req)) (let* ((th1 (make-thread (lambda () (let ((resp (nng-recv req))) (nng-close! req) (print resp) (set! res resp))) "recv thread")) (th2 (make-thread (lambda () (thread-sleep! timeout) (thread-terminate! th1)) "timer thread"))) |
︙ | ︙ |
Deleted server.scm version [7011752052].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |