Overview
Comment: | Better server and sync run-away protection using dot files in the users tmp db area. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.64 | v1.6424 |
Files: | files | file ages | folders |
SHA1: |
30074493838bdab3cf7e4bf1aa65d913 |
User & Date: | matt on 2017-07-11 22:43:26 |
Other Links: | branch diff | manifest | tags |
Context
2017-07-12
| ||
18:36 | server connection tag check-in: 6b1258c69a user: mrwellan tags: v1.64-server-connection-tagging | |
17:13 | increase default expiration time to 1400 hours from 1 hour. added server/time-to-die-seconds to allow future trimming check-in: e396b98a87 user: bjbarcla tags: v1.64 | |
2017-07-11
| ||
22:43 | Better server and sync run-away protection using dot files in the users tmp db area. check-in: 3007449383 user: matt tags: v1.64, v1.6424 | |
15:54 | Fixed rollup of DEAD. check-in: 44fee9274f user: mrwellan tags: v1.64 | |
Changes
cgisetup/cgi-bin/models became a symlink with target [39c07627cc].
cgisetup/cgi-bin/pages became a symlink with target [e2b5ed002d].
Modified db.scm from [d861a30e88] to [08b5e15dd9].
︙ | |||
1899 1900 1901 1902 1903 1904 1905 | 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 | - - - - - - - - - - + + + + + + + + + + + | ;; transaction protected lock aquisition ;; either: ;; fails returns (#f . lock-creation-time) ;; succeeds (returns (#t . lock-creation-time) ;; use (db:no-sync-del! db keyname) to release the lock ;; |
︙ |
Modified http-transport.scm from [1066bc8fad] to [91f92e466a].
︙ | |||
55 56 57 58 59 60 61 | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | - + + + + | (hostname (get-host-name)) (ipaddrstr (let ((ipstr (if (string=? "-" hostn) ;; (string-intersperse (map number->string (u8vector->list (hostname->ip hostname))) ".") (server:get-best-guess-address hostname) #f))) (if ipstr ipstr hostn))) ;; hostname))) (start-port (portlogger:open-run-close portlogger:find-port)) |
︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | + | (send-response body: "hey there!\n" headers: '((content-type text/plain)))) ((equal? (uri-path (request-uri (current-request))) '(/ "hey")) (send-response body: "hey there!\n" headers: '((content-type text/plain)))) (else (continue)))))))) (with-output-to-file start-file (lambda ()(print (current-process-id)))) (http-transport:try-start-server ipaddrstr start-port))) ;; This is recursively run by http-transport:run until sucessful ;; (define (http-transport:try-start-server ipaddrstr portnum) (let ((config-hostname (configf:lookup *configdat* "server" "hostname")) (config-use-proxy (equal? (configf:lookup *configdat* "client" "use-http_proxy") "yes"))) |
︙ | |||
346 347 348 349 350 351 352 | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | + + - + | ;; used and to shutdown after sometime if it is not. ;; (define (http-transport:keep-running) ;; if none running or if > 20 seconds since ;; server last used then start shutdown ;; This thread waits for the server to come alive (debug:print-info 0 *default-log-port* "Starting the sync-back, keep alive thread in server") (let* ((tmp-area (common:get-db-tmp-area)) (started-file (conc tmp-area "/.server-started")) |
︙ | |||
378 379 380 381 382 383 384 385 386 387 388 389 390 391 | 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | + + + | sdat))))))) (iface (car server-info)) (port (cadr server-info)) (last-access 0) (server-timeout (server:get-timeout)) (server-going #f) (server-log-file (args:get-arg "-log"))) ;; always set when we are a server (with-output-to-file started-file (lambda ()(print (current-process-id)))) (let loop ((count 0) (server-state 'available) (bad-sync-count 0) (start-time (current-milliseconds))) ;; Use this opportunity to sync the tmp db to megatest.db (if (not server-going) ;; *dbstruct-db* (begin |
︙ | |||
490 491 492 493 494 495 496 497 498 499 500 501 502 503 | 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | + + + + + + + + + + + + + | (exit))) ;; all routes though here end in exit ... ;; ;; start_server? ;; (define (http-transport:launch) ;; check that a server start is in progress, pause or exit if so (let* ((tmp-area (common:get-db-tmp-area)) (server-start (conc tmp-area "/.server-start")) (server-started (conc tmp-area "/.server-started")) (start-time (common:lazy-modification-time server-start)) (started-time (common:lazy-modification-time server-started)) (server-starting (< start-time started-time)) ;; if start-time is less than started-time then a server is still starting (start-time-old (> (- (current-seconds) start-time) 5))) (if (and (not start-time-old) ;; last server start try was less than five seconds ago (not server-starting)) (begin (debug:print-info 0 *default-log-port* "NOT starting server, there is either a recently started server or a server in process of starting") (exit)))) ;; lets not even bother to start if there are already three or more server files ready to go (let* ((num-alive (server:get-num-alive (server:get-list *toppath*)))) (if (> num-alive 3) (begin (debug:print 0 *default-log-port* "ERROR: Aborting server start because there are already " num-alive " possible servers either running or starting up") (exit)))) (let* ((th2 (make-thread (lambda () |
︙ | |||
514 515 516 517 518 519 520 | 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + | (thread-start! th2) (thread-sleep! 0.25) ;; give the server time to settle before starting the keep-running monitor. (thread-start! th3) (set! *didsomething* #t) (thread-join! th2) (exit))) |
︙ |
Modified server.scm from [d90e3727cd] to [52a482f03f].
︙ | |||
463 464 465 466 467 468 469 | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | - - + + + + + + + + + + + - + + + + - + + + + + + + - + | (sync-duration 0) ;; run time of the sync in milliseconds (this-wd-num (begin (mutex-lock! *wdnum*mutex) (let ((x *wdnum*)) (set! *wdnum* (add1 *wdnum*)) (mutex-unlock! *wdnum*mutex) x)))) (set! *no-sync-db* no-sync-db) ;; make the no sync db available to api calls (debug:print-info 2 *default-log-port* "Periodic sync thread started.") (debug:print-info 3 *default-log-port* "watchdog starting. legacy-sync is " legacy-sync" pid="(current-process-id)" this-wd-num="this-wd-num) (if (and legacy-sync (not *time-to-exit*)) (let* (;;(dbstruct (db:setup)) |
︙ | |||
524 525 526 527 528 529 530 531 532 533 534 535 536 537 | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | + + + + | (loop (read-line) (or num-synced res)))))))))) (if will-sync (begin (mutex-lock! *db-multi-sync-mutex*) (set! *db-sync-in-progress* #f) (set! *db-last-sync* start-time) (with-output-to-file end-file (lambda ()(print (current-process-id)))) ;; release lock here (mutex-unlock! *db-multi-sync-mutex*))) (if (and debug-mode (> (- start-time last-time) 60)) (begin (set! last-time start-time) (debug:print-info 4 *default-log-port* "timestamp -> " (seconds->time-string (current-seconds)) ", time since start -> " (seconds->hr-min-sec (- (current-seconds) *time-zero*)))))) |
︙ |