picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

replica (943B)


      1 #!bin/picolisp lib.l
      2 # 03aug13abu
      3 # Use: bin/replica <port> <keyFile> <journal> <dbFile> <blob/app/> [dbs1 ..]
      4 #    : bin/ssl <host> 443 '<port>/!replica' <keyFile> <journal> <blob/app/> 60
      5 
      6 (load "@lib/misc.l" "@lib/http.l")
      7 
      8 (allowed NIL "!replica")
      9 
     10 (argv *Port *KeyFile *Journal *Pool *Blob . *Dbs)
     11 
     12 (setq
     13    *Port (format *Port)
     14    *SSLKey (in *KeyFile (line T)) )
     15 
     16 (de replica ()
     17    (ctl *KeyFile
     18       (protect
     19          (when (= (line T) *SSLKey)
     20             (let? X (line T)
     21                (if (format X)
     22                   (when (abort 420 (out (tmp 'replica) (echo @)))  # Journal
     23                      (prin (peek))
     24                      (flush)
     25                      (journal (tmp 'replica)) )
     26                   (let Blob (pack *Blob X)                         # Blob
     27                      (call 'mkdir "-p" (dirname Blob))
     28                      (out Blob (echo)) ) ) ) ) ) ) )
     29 
     30 (pool *Pool (mapcar format *Dbs) *Journal)
     31 (server *Port)