Overview
Comment: | wip |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.6584-ck5 |
Files: | files | file ages | folders |
SHA1: |
febc25a845277b7bdba6187fe67ab5f2 |
User & Date: | matt on 2021-05-13 23:46:10 |
Other Links: | branch diff | manifest | tags |
Context
2021-05-14
| ||
06:02 | wip check-in: 4fdbc16a0c user: matt tags: v1.6584-ck5 | |
2021-05-13
| ||
23:46 | wip check-in: febc25a845 user: matt tags: v1.6584-ck5 | |
2021-05-11
| ||
23:21 | wip check-in: 4be151ee72 user: matt tags: v1.6584-ck5 | |
Changes
Modified Makefile from [a8160d56aa] to [3644a50f76].
︙ | |||
87 88 89 90 91 92 93 | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | - + | mofiles/keysmod.o : mofiles/debugprint.o mofiles/launchmod.o : mofiles/bigmod.o mofiles/launchmod.o : mofiles/ezstepsmod.o mofiles/launchmod.o : mofiles/rmtmod.o mofiles/servermod.o mofiles/mtmod.o : mofiles/debugprint.o mofiles/portloggermod.o : mofiles/tasksmod.o mofiles/rmtmod.o : mofiles/apimod.o |
︙ |
Modified apimod.scm from [f3706ab7e3] to [1fc312f537].
︙ | |||
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | + + | chicken.base chicken.process-context.posix chicken.string chicken.time chicken.condition chicken.process chicken.random chicken.file ;; (prefix sqlite3 sqlite3:) typed-records srfi-18 srfi-69 commonmod dbmod debugprint tasksmod servermod matchable ) ;; allow these queries through without starting a server ;; (define api:read-only-queries '(get-key-val-pairs get-var |
︙ | |||
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | testmeta-update-field ;; TASKS tasks-add tasks-set-state-given-param-key )) (define (api:run-server-process apath dbname) (let* ((cmd (conc "nbfake megatest -server - -area "apath " -db "dbname)) (cleandbname (string-translate dbname "./" "_-")) (logd (conc apath "/logs")) (logf (conc logd "/server-"(current-seconds)cleandbname".log"))) (if (not (directory-exists? logd)) (create-directory logd #t)) (system (conc "NBFAKE_LOG="logf" "cmd)))) ;; special function to get server ;; look up in db ;; if found -> return it ;; if not found -> start server, return starting ;; (define (api:start-server dbstruct params) (let* ((res (apply db:get-server-info dbstruct params))) (if res res (match params ((apath dbname) (api:run-server-process apath dbname) 'server-started) (else (debug:print-info 0 *default-log-port* "api:start-server called with wrong params: "params) 'bad-params))))) (define (api:dispatch-cmd dbstruct cmd params) (case cmd ;;=============================================== ;; READ/WRITE QUERIES ;;=============================================== ((get-keys-write) (db:get-keys dbstruct)) ;; force a dummy "write" query to force server; for debug in -repl ;; SERVERS ;; ((start-server) (apply server:kind-run params)) ((kill-server) (set! *server-run* #f)) |
︙ | |||
338 339 340 341 342 343 344 | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + | ;; TASKS ((find-task-queue-records) (apply tasks:find-task-queue-records dbstruct params)) (else (debug:print 0 *default-log-port* "ERROR: bad api call " cmd) (conc "ERROR: BAD api call " cmd)))) |
︙ | |||
394 395 396 397 398 399 400 | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | - + | ;; http-server send-response ;; api:process-request ;; db:* ;; ;; NB// Runs on the server as part of the server loop ;; (define (api:process-request dbstruct $) ;; the $ is the request vars proc |
︙ |
Modified dbmod.scm from [ee5770769f] to [df51662aee].
︙ | |||
163 164 165 166 167 168 169 | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | - - + + | (let* (;; (dbfile (db:run-id->path apath run-id)) (newdbdat (db:open-dbdat apath dbfile db:initialize-db))) (dbr:dbstruct-dbdat-put! dbstruct dbfile newdbdat) newdbdat)))) ;; get the inmem db for actual db operations ;; |
︙ | |||
323 324 325 326 327 328 329 | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | + - + | )) ;; (db:with-db dbstruct run-id sqlite3:exec "select blah fgrom blaz;") ;; r/w is a flag to indicate if the db is modified by this query #t = yes, #f = no ;; (define (db:with-db dbstruct run-id r/w proc . params) (assert (dbr:dbstruct? dbstruct) "FATAL: db:with-db called with bad dbstruct") (let* ((dbpath (db:run-id->dbname run-id)) |
︙ | |||
5523 5524 5525 5526 5527 5528 5529 | 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 | - + - + - + | (db:with-db dbstruct #f #f (lambda (db) (sqlite3:execute db "INSERT INTO servers (host,port,servkey,pid,ipaddr,dbpath) VALUES (?,?,?,?,?,?);" host port servkey pid ipaddr dbpath)))) |
Modified http-transportmod.scm from [b05b0793f5] to [eede86b1be].
︙ | |||
140 141 142 143 144 145 146 | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | - + - + + | ;; (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)) (link-tree-path (common:get-linktree)) (tmp-area (common:get-db-tmp-area)) |
︙ | |||
305 306 307 308 309 310 311 | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + | (mutex-lock! *http-mutex*) (set! *http-requests-in-progress* (+ 1 *http-requests-in-progress*))) ;; serverdat contains uuid to be used for connection validation ;; ;; NOTE: serverdat must be initialized or created by servdat-init ;; ;; DO NOT USE. Moved to rmt:set-receive-real ;; |
︙ |
Modified rmtmod.scm from [793347499a] to [7173063106].
︙ | |||
166 167 168 169 170 171 172 173 174 175 176 177 178 179 | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | + + + + + | (srvpkt #f) (lastmsg 0) (expires 0)) ;; replaces *runremote* (define *rmt:remote* (make-rmt:remote)) ;; -> http://abc.com:900/<entrypoint> ;; (define (rmt:conn->uri conn entrypoint) (conc "http://"(rmt:conn-ipaddr conn)":"(rmt:conn-port conn)"/"entrypoint)) ;; set up the api proc, seems like there should be a better place for this? (api-proc api:process-request) ;; do we have a connection to apath dbname and ;; is it not expired? then return it ;; ;; else setup a connection |
︙ | |||
199 200 201 202 203 204 205 | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | - - + | ;; connections for other servers happens by requesting from main ;; (define (rmt:open-main-connection remote apath) (let* ((dbname (db:run-id->dbname #f)) (the-srv (rmt:find-main-server apath dbname)) (start-main-srv (lambda () ;; srv not ready, delay a little and try again |
︙ | |||
233 234 235 236 237 238 239 240 241 242 243 244 245 | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | + - - + + + - - + + - + + + + + + + + + + + + + + + + + + | (start-main-srv))) (start-main-srv)))) ;; NB// remote is a rmt:remote struct ;; (define (rmt:general-open-connection remote apath dbname) (let ((mainconn (rmt:get-connection remote apath (db:run-id->dbname #f)))) (debug:print 0 *default-log-port* "remote: " remote) (if (not mainconn) (begin (rmt:open-main-connection remote apath) (thread-sleep! 1) (rmt:general-open-connection remote apath dbname)) ;; we have a connection to main, ask for contact info for dbname |
︙ | |||
1552 1553 1554 1555 1556 1557 1558 | 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 | - + + | (let* ((server-url (server:record->url server-record)) (server-id (server:record->id server-record)) (res (server:ping server-url server-id))) (if res server-url #f))) |
︙ |
Modified tests/unittests/basicserver.scm from [393aa77a21] to [9df3f5b6e7].
︙ | |||
18 19 20 21 22 23 24 | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | - + + + + - - + + | ;; You should have received a copy of the GNU General Public License ;; along with Megatest. If not, see <http://www.gnu.org/licenses/>. ;; Run like this: ;; ;; ./rununittest.sh server 1;(cd simplerun;megatest -stop-server 0) |
︙ |