Removing separate processes and trying to get faster turn-around, plus a few little things

This commit is contained in:
Jay McCarthy 2014-09-29 13:12:44 -04:00
parent 368385a2e6
commit 3bd9ab669f
9 changed files with 102 additions and 76 deletions

View File

@ -5,7 +5,8 @@
racket/port racket/port
net/http-client net/http-client
(prefix-in pkg: pkg/lib) (prefix-in pkg: pkg/lib)
"common.rkt") "common.rkt"
"notify.rkt")
(define SUMMARY-HOST "pkg-build.racket-lang.org") (define SUMMARY-HOST "pkg-build.racket-lang.org")
(define SUMMARY-URL (string-append "/" SUMMARY-NAME)) (define SUMMARY-URL (string-append "/" SUMMARY-NAME))
@ -66,11 +67,22 @@
(rename-file-or-directory new-file SUMMARY-PATH #t))) (rename-file-or-directory new-file SUMMARY-PATH #t)))
(define (do-build-update! l)
(notify! "package build status being checked for updates")
(build-update!)
(notify! ""))
(define (run-build-update!)
(run! do-build-update! empty))
(define (signal-build-update!)
(thread (λ () (run-build-update!))))
(provide do-build-update!
run-build-update!
signal-build-update!)
(module+ main (module+ main
(require racket/cmdline) (require racket/cmdline)
(command-line (command-line
#:program "build-update" #:program "build-update"
#:args () #:args ()
(notify! "package build status being checked for updates") (do-build-update! empty)))
(build-update!)
(notify! "")))

View File

@ -35,6 +35,7 @@
(define static.src-path (build-path src "static")) (define static.src-path (build-path src "static"))
(define static-path (build-path src "static-gen")) (define static-path (build-path src "static-gen"))
(define notice-path (format "~a/notice.json" static-path))
(define (package-list) (define (package-list)
(sort (map path->string (directory-list pkgs-path)) (sort (map path->string (directory-list pkgs-path))
@ -92,44 +93,12 @@
(define valid-tag? (define valid-tag?
valid-name?) valid-name?)
(define-runtime-path update.rkt "update.rkt")
(define-runtime-path build-update.rkt "build-update.rkt")
(define-runtime-path static.rkt "static.rkt")
(define-runtime-path s3.rkt "s3.rkt")
(define-runtime-path notify.rkt "notify.rkt")
(define run-sema (make-semaphore 1)) (define run-sema (make-semaphore 1))
(define (run! file args) (define (run! f args)
(call-with-semaphore (parameterize ([date-display-format 'iso-8601])
run-sema (printf "~a: ~a ~v\n" (date->string (current-date) #t) f args)
(λ () (f args)
(parameterize ([date-display-format 'iso-8601]) (printf "~a: done\n" (date->string (current-date) #t))))
(printf "~a: ~a ~v\n" (date->string (current-date) #t) file args))
(apply system* (find-executable-path (find-system-path 'exec-file))
"-t" file
"--"
args)
(printf "~a: done\n" (date->string (current-date) #t)))))
(define (run-update! pkgs)
(run! update.rkt pkgs))
(define (run-build-update!)
(run! build-update.rkt empty))
(define (run-static! pkgs)
(run! static.rkt pkgs))
(define (run-s3! pkgs)
(run! s3.rkt pkgs))
(define (notify! m)
(run! notify.rkt (list m)))
(define (signal-update! pkgs)
(thread (λ () (run-update! pkgs))))
(define (signal-build-update!)
(thread (λ () (run-build-update!))))
(define (signal-static! pkgs)
(thread (λ () (run-static! pkgs))))
(define (signal-s3! pkgs)
(thread (λ () (run-s3! pkgs))))
(define s3-config (build-path (find-system-path 'home-dir) ".s3cfg-plt")) (define s3-config (build-path (find-system-path 'home-dir) ".s3cfg-plt"))
(define s3-bucket "pkgs.racket-lang.org") (define s3-bucket "pkgs.racket-lang.org")

View File

@ -1,6 +1,10 @@
#lang racket/base #lang racket/base
(require web-server/http (require web-server/http
"common.rkt" "common.rkt"
"update.rkt"
"notify.rkt"
"static.rkt"
"build-update.rkt"
"jsonp.rkt" "jsonp.rkt"
web-server/servlet-env web-server/servlet-env
racket/file racket/file
@ -390,6 +394,9 @@
(signal-update! (packages-of (current-user))) (signal-update! (packages-of (current-user)))
#t) #t)
(define jsonp/notice
(make-jsonp-responder (λ (args) (file->string notice-path))))
(define-values (main-dispatch main-url) (define-values (main-dispatch main-url)
(dispatch-rules (dispatch-rules
[("jsonp" "authenticate") jsonp/authenticate] [("jsonp" "authenticate") jsonp/authenticate]
@ -404,6 +411,7 @@
[("jsonp" "package" "author" "del") jsonp/package/author/del] [("jsonp" "package" "author" "del") jsonp/package/author/del]
[("jsonp" "package" "curate") jsonp/package/curate] [("jsonp" "package" "curate") jsonp/package/curate]
[("api" "upload") #:method "post" api/upload] [("api" "upload") #:method "post" api/upload]
[("jsonp" "notice") jsonp/notice]
[else redirect-to-static])) [else redirect-to-static]))
(define-syntax-rule (forever . body) (define-syntax-rule (forever . body)

View File

@ -7,20 +7,7 @@
"common.rkt") "common.rkt")
(define (upload-notice! m) (define (upload-notice! m)
(define notice-p (format "~a/notice.json" static-path)) (display-to-file m notice-path #:exists 'replace))
(write-to-file m notice-p #:exists 'replace)
(system* s3cmd-path
"-c" s3-config
"sync"
"-M"
"--acl-public"
"--delete-removed"
notice-p
(format "s3://~a/notice.json" s3-bucket))
(void))
(module+ main (module+ main
(require racket/cmdline) (require racket/cmdline)
@ -28,3 +15,11 @@
#:program "notify" #:program "notify"
#:args (message) #:args (message)
(upload-notice! message))) (upload-notice! message)))
(define (do-notify! l)
(upload-notice! (first l)))
(define (notify! m)
(run! do-notify! (list m)))
(provide do-notify!
notify!)

View File

@ -5,7 +5,8 @@
racket/system racket/system
file/gzip file/gzip
racket/match racket/match
"common.rkt") "common.rkt"
"notify.rkt")
(define (upload-all) (define (upload-all)
(gzip (format "~a/pkgs-all.json" static-path) (gzip (format "~a/pkgs-all.json" static-path)
@ -39,6 +40,14 @@
(define (upload-pkgs pkgs) (define (upload-pkgs pkgs)
;; FUTURE make this more efficient ;; FUTURE make this more efficient
(upload-all)) (upload-all))
(define (run-s3! pkgs)
(run! upload-pkgs pkgs))
(define (signal-s3! pkgs)
(thread (λ () (run-s3! pkgs))))
(provide upload-pkgs
run-s3!
signal-s3!)
(module+ main (module+ main
(require racket/cmdline) (require racket/cmdline)

View File

@ -13,7 +13,9 @@
racket/path racket/path
racket/promise racket/promise
meta/pkg-index/basic/main meta/pkg-index/basic/main
"common.rkt") "common.rkt"
"notify.rkt"
"s3.rkt")
(define convert-to-json (define convert-to-json
(match-lambda (match-lambda
@ -373,13 +375,24 @@
(delete-file (build-path pkg-path f)) (delete-file (build-path pkg-path f))
(delete-file (build-path pkg-path (path-add-suffix f #".json"))))))) (delete-file (build-path pkg-path (path-add-suffix f #".json")))))))
(define (do-static pkgs)
(notify! "update upload being computed: the information below may not represent all recent changes and updates")
;; FUTURE make this more efficient by looking at pkgs
(generate-static)
(run-s3! pkgs))
(define (run-static! pkgs)
(run! do-static pkgs))
(define (signal-static! pkgs)
(thread (λ () (run-static! pkgs))))
(provide do-static
run-static!
signal-static!)
(module+ main (module+ main
(require racket/cmdline) (require racket/cmdline)
(command-line (command-line
#:program "static" #:program "static"
#:args pkgs #:args pkgs
;; FUTURE make this more efficient (do-static pkgs)))
(notify! "update upload being computed: the information below may not represent all recent changes and updates")
(generate-static)
(run-s3! pkgs)))

View File

@ -506,16 +506,17 @@ $( document ).ready(function() {
bstatus ); } bstatus ); }
function pollNotice(){ function pollNotice(){
$.getJSON( "/notice.json", function( resp ) { $.getJSON( dynamic_url("/jsonp/notice"), function( resp ) {
$("#server_notice").html(resp); $("#server_notice").html(resp);
// If there is no notice, update every 5 minutes // If there is no notice, update every 5 minutes
if ( resp == "" ) { if ( ! (/\S/.test(resp)) ) {
$("#server_notice").hide(); $("#server_notice").hide();
setTimeout(pollNotice, 1000*60*5); } setTimeout(pollNotice, 1000*60*5); }
// Otherwise, update every 5 seconds // Otherwise, update every 5 seconds
else { else {
$("#server_notice").show(); $("#server_notice").show();
setTimeout(pollNotice, 1000*5); } }); } setTimeout(pollNotice, 1000*5); } }); }
$("#server_notice").hide();
pollNotice(); pollNotice();
var pkgdb = {}; var pkgdb = {};
@ -601,6 +602,9 @@ $( document ).ready(function() {
function menu_logout () { function menu_logout () {
logged_in = false; logged_in = false;
$("#logout").html( jslink( "login", function () { $( "#login" ).dialog( "open" ); } ) ); } $("#logout").html( jslink( "login", function () { $( "#login" ).dialog( "open" ); } ) ); }
function menu_logging () {
logged_in = false;
$("#logout").html( "logging in..." ); }
function menu_loggedin ( curate_p ) { function menu_loggedin ( curate_p ) {
logged_in = true; logged_in = true;
$("#logout").html("") $("#logout").html("")
@ -656,6 +660,7 @@ $( document ).ready(function() {
menu_logout (); }) ); } menu_logout (); }) ); }
function initial_login () { function initial_login () {
menu_logging();
$.getJSON( dynamic_url("/jsonp/authenticate"), $.getJSON( dynamic_url("/jsonp/authenticate"),
{ email: localStorage['email'], passwd: localStorage['passwd'], code: "" }, { email: localStorage['email'], passwd: localStorage['passwd'], code: "" },
function( resp ) { function( resp ) {

View File

@ -45,14 +45,15 @@ body {
#server_notice { #server_notice {
text-align: center; text-align: center;
background: #ffffcc; background: #ffffcc;
padding-bottom: 0.5em; padding-bottom: 0.25em;
color: black; color: black;
font-size: 150%; font-size: 75%;
font-weight: bold; font-weight: bold;
} }
#logout { #logout {
float: right; float: right;
color: white;
} }
.content { .content {

View File

@ -4,7 +4,9 @@
pkg/util pkg/util
racket/package racket/package
(prefix-in pkg: pkg/lib) (prefix-in pkg: pkg/lib)
"common.rkt") "common.rkt"
"notify.rkt"
"static.rkt")
(define (update-all) (define (update-all)
(update-checksums #f (package-list))) (update-checksums #f (package-list)))
@ -77,16 +79,28 @@
(define* i (hash-set i 'dependencies dependencies)) (define* i (hash-set i 'dependencies dependencies))
i)) i))
(define (do-update! pkgs)
(notify! "package sources being checked for updates")
(cond
[(empty? pkgs)
(update-all)
(run-static! empty)]
[else
(update-pkgs pkgs)
(run-static! pkgs)]))
(define (run-update! pkgs)
(run! do-update! pkgs))
(define (signal-update! pkgs)
(thread (λ () (run-update! pkgs))))
(provide do-update!
run-update!
signal-update!)
(module+ main (module+ main
(require racket/cmdline) (require racket/cmdline)
(command-line (command-line
#:program "update" #:program "update"
#:args pkgs #:args pkgs
(notify! "package sources being checked for updates") (do-update! pkgs)))
(cond
[(empty? pkgs)
(update-all)
(run-static! empty)]
[else
(update-pkgs pkgs)
(run-static! pkgs)])))