s3 sync
This commit is contained in:
parent
975d06db7f
commit
17315f5737
|
@ -4,3 +4,4 @@
|
|||
/static/pkgs-all
|
||||
*json
|
||||
/static/atom.xml
|
||||
/static.gz
|
||||
|
|
|
@ -373,12 +373,19 @@
|
|||
[("api" "upload") #:method "post" api/upload]
|
||||
[else redirect-to-static]))
|
||||
|
||||
(define-syntax-rule (forever . body)
|
||||
(let loop () (begin . body) (loop)))
|
||||
|
||||
(define (go port)
|
||||
(printf "launching on port ~a\n" port)
|
||||
(signal-static! empty)
|
||||
(thread
|
||||
(λ ()
|
||||
(forever
|
||||
(sleep (* 24 60 60))
|
||||
(signal-update! empty))))
|
||||
(serve/servlet
|
||||
(λ (req)
|
||||
;; (displayln (url->string (request-uri req)))
|
||||
(main-dispatch req))
|
||||
main-dispatch
|
||||
#:command-line? #t
|
||||
#:listen-ip #f
|
||||
#:ssl? #t
|
||||
|
|
|
@ -1,9 +1,49 @@
|
|||
#lang racket/base
|
||||
(require racket/list
|
||||
racket/file
|
||||
racket/path
|
||||
racket/system
|
||||
file/gzip
|
||||
racket/match
|
||||
"common.rkt")
|
||||
|
||||
(define (make-parent-directory* p)
|
||||
(make-directory* (path-only p)))
|
||||
|
||||
(define s3-config (build-path (find-system-path 'home-dir) ".s3cfg-plt"))
|
||||
(define s3-bucket "pkg.racket-lang.org")
|
||||
|
||||
(define static.gz-path (path-add-suffix static-path ".gz"))
|
||||
|
||||
(define s3cmd-path (find-executable-path "s3cmd"))
|
||||
|
||||
(define (upload-all)
|
||||
(error 'upload-all "XXX"))
|
||||
(define root (simple-form-path static-path))
|
||||
|
||||
(for ([f (in-directory root)]
|
||||
#:when (file-exists? f))
|
||||
(define f.time (file-or-directory-modify-seconds f))
|
||||
|
||||
(define rf (find-relative-path root f))
|
||||
(define gf (build-path static.gz-path rf))
|
||||
(make-parent-directory* gf)
|
||||
|
||||
(define g.time (file-or-directory-modify-seconds gf))
|
||||
|
||||
(when (> f.time g.time)
|
||||
(printf "gzipping ~a\n" f)
|
||||
(gzip f gf)))
|
||||
|
||||
(system* s3cmd-path
|
||||
"-c" s3-config
|
||||
"sync"
|
||||
"-M"
|
||||
"--acl-public"
|
||||
"--add-header" "Content-Encoding:gzip"
|
||||
"--delete-removed"
|
||||
(format "~a/" static.gz-path)
|
||||
(format "s3://~a/" s3-bucket)))
|
||||
|
||||
(define (upload-pkgs pkgs)
|
||||
;; FUTURE make this more efficient
|
||||
(upload-all))
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// xxx change these to the real thing
|
||||
var dynamic_host = "localhost";
|
||||
var dynamic_host = "pkg-dyn.racket-lang.org";
|
||||
var dynamic_port = 9004;
|
||||
|
||||
function dynamic_url ( u ) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user