make a launcher for standalone help-desk server, option for port number to listen on
svn: r7174
This commit is contained in:
parent
592be14b81
commit
897d92c3cf
|
@ -1,4 +1,4 @@
|
||||||
;;; launch.ss
|
(module help-desk-server mzscheme
|
||||||
|
|
||||||
;; PURPOSE
|
;; PURPOSE
|
||||||
;; This file launches a web-server serving an online
|
;; This file launches a web-server serving an online
|
||||||
|
@ -8,23 +8,33 @@
|
||||||
|
|
||||||
;; NOTES
|
;; NOTES
|
||||||
;; The web-server uses the port given by internal-port
|
;; The web-server uses the port given by internal-port
|
||||||
;; in "collects/help/private/internal-hp.ss".
|
;; in "private/options.ss" by default.
|
||||||
|
|
||||||
|
;; Startpage:
|
||||||
|
;; http://localhost:8012/servlets/home.ss
|
||||||
|
;; (where 8012 is the port given by internal-port)
|
||||||
|
|
||||||
;; Startpage:
|
|
||||||
;; http://localhost:8000/servlets/home.ss
|
|
||||||
;; (where 8000 is the port given by internal-port)
|
|
||||||
|
|
||||||
(require (lib "web-server.ss" "web-server")
|
(require (lib "web-server.ss" "web-server")
|
||||||
(lib "web-config-unit.ss" "web-server")
|
(lib "web-config-unit.ss" "web-server")
|
||||||
"private/config.ss"
|
"private/config.ss"
|
||||||
(only "private/internal-hp.ss" internal-host)
|
"private/internal-hp.ss"
|
||||||
"private/options.ss")
|
"private/options.ss"
|
||||||
|
(lib "cmdline.ss"))
|
||||||
|
|
||||||
(helpdesk-platform 'external-browser)
|
(helpdesk-platform 'external-browser)
|
||||||
|
|
||||||
|
(command-line
|
||||||
|
"help-desk-server"
|
||||||
|
(current-command-line-arguments)
|
||||||
|
(once-each
|
||||||
|
[("-p" "--port") port "port to run on"
|
||||||
|
(internal-port (string->number port))]))
|
||||||
|
(printf "launch>>>> ~s\n" (internal-port))
|
||||||
|
|
||||||
;; start the HelpDesk server, and store a shutdown
|
;; start the HelpDesk server, and store a shutdown
|
||||||
(define shutdown
|
(define shutdown
|
||||||
(serve/web-config@ config))
|
(serve/web-config@ (make-config)))
|
||||||
|
|
||||||
(printf "\nStart here: http://~a:~a/servlets/home.ss\n\n"
|
(printf "\nStart here: http://~a:~a/servlets/home.ss\n\n"
|
||||||
internal-host (internal-port))
|
internal-host (internal-port))
|
||||||
|
@ -32,3 +42,5 @@
|
||||||
(printf "Press enter to shutdown.\n")
|
(printf "Press enter to shutdown.\n")
|
||||||
(read-line)
|
(read-line)
|
||||||
;(shutdown)
|
;(shutdown)
|
||||||
|
|
||||||
|
)
|
|
@ -2,7 +2,7 @@
|
||||||
(module info (lib "infotab.ss" "setup")
|
(module info (lib "infotab.ss" "setup")
|
||||||
(define name "Help")
|
(define name "Help")
|
||||||
(define doc.txt "doc.txt")
|
(define doc.txt "doc.txt")
|
||||||
(define compile-subcollections
|
(define compile-subcollections
|
||||||
'(("help" "private")
|
'(("help" "private")
|
||||||
("help" "servlets")
|
("help" "servlets")
|
||||||
("help" "servlets" "private")
|
("help" "servlets" "private")
|
||||||
|
@ -13,7 +13,9 @@
|
||||||
("help" "servlets" "scheme" "misc")))
|
("help" "servlets" "scheme" "misc")))
|
||||||
(define help-desk-message
|
(define help-desk-message
|
||||||
"Mr: (require (lib \"help-desk.ss\" \"help\"))")
|
"Mr: (require (lib \"help-desk.ss\" \"help\"))")
|
||||||
(define mred-launcher-libraries (list "help.ss"))
|
(define mred-launcher-libraries '("help.ss"))
|
||||||
(define mred-launcher-names (list "Help Desk"))
|
(define mred-launcher-names '("Help Desk"))
|
||||||
|
(define mzscheme-launcher-libraries '("help-desk-server.ss"))
|
||||||
|
(define mzscheme-launcher-names '("Help Desk Server"))
|
||||||
(define install-collection "installer.ss")
|
(define install-collection "installer.ss")
|
||||||
(define compile-omit-files '("launch.ss")))
|
(define compile-omit-files '("launch.ss")))
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
"internal-hp.ss"
|
"internal-hp.ss"
|
||||||
(lib "namespace.ss" "web-server" "configuration"))
|
(lib "namespace.ss" "web-server" "configuration"))
|
||||||
|
|
||||||
(provide config)
|
(provide make-config)
|
||||||
|
|
||||||
(define config
|
(define (make-config)
|
||||||
(let* ([build-normal-path
|
(let* ([build-normal-path
|
||||||
(lambda args
|
(lambda args
|
||||||
(normalize-path
|
(normalize-path
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
(mime-types "../../web-server/default-web-root/mime.types")
|
(mime-types "../../web-server/default-web-root/mime.types")
|
||||||
(password-authentication "passwords"))))])
|
(password-authentication "passwords"))))])
|
||||||
(configuration-table-sexpr->web-config@
|
(configuration-table-sexpr->web-config@
|
||||||
`((port ,internal-port)
|
`((port ,(internal-port))
|
||||||
(max-waiting 40)
|
(max-waiting 40)
|
||||||
(initial-connection-timeout 30)
|
(initial-connection-timeout 30)
|
||||||
(default-host-table
|
(default-host-table
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
(λ (segments anchor)
|
(λ (segments anchor)
|
||||||
(format "http://~a:~a/servlets/static.ss/~a~a~a"
|
(format "http://~a:~a/servlets/static.ss/~a~a~a"
|
||||||
internal-host
|
internal-host
|
||||||
internal-port
|
(internal-port)
|
||||||
host
|
host
|
||||||
(apply string-append (map (λ (x) (format "/~a" (path->string x)))
|
(apply string-append (map (λ (x) (format "/~a" (path->string x)))
|
||||||
segments))
|
segments))
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
url]
|
url]
|
||||||
|
|
||||||
;; one of the "collects" hosts:
|
;; one of the "collects" hosts:
|
||||||
[(and (equal? internal-port (url-port url))
|
[(and (equal? (internal-port) (url-port url))
|
||||||
(ormap (lambda (host)
|
(ormap (lambda (host)
|
||||||
(equal? host (url-host url)))
|
(equal? host (url-host url)))
|
||||||
doc-hosts))
|
doc-hosts))
|
||||||
|
@ -160,7 +160,7 @@
|
||||||
url))]
|
url))]
|
||||||
|
|
||||||
;; one of the other internal hosts
|
;; one of the other internal hosts
|
||||||
[(and (equal? internal-port (url-port url))
|
[(and (equal? (internal-port) (url-port url))
|
||||||
(is-internal-host? (url-host url)))
|
(is-internal-host? (url-host url)))
|
||||||
url]
|
url]
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@
|
||||||
(mixin (hyper-text<%> editor<%>) ()
|
(mixin (hyper-text<%> editor<%>) ()
|
||||||
(define/augment (url-allows-evaling? url)
|
(define/augment (url-allows-evaling? url)
|
||||||
(and (is-internal-host? (url-host url))
|
(and (is-internal-host? (url-host url))
|
||||||
(equal? internal-port (url-port url))))
|
(equal? (internal-port) (url-port url))))
|
||||||
|
|
||||||
(define show-sk? #t)
|
(define show-sk? #t)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
(require (lib "dirs.ss" "setup")
|
(require (lib "dirs.ss" "setup")
|
||||||
(lib "config.ss" "planet")
|
(lib "config.ss" "planet")
|
||||||
"options.ss")
|
"options.ss")
|
||||||
(provide (rename internal-port* internal-port)
|
(provide internal-port
|
||||||
is-internal-host? internal-host
|
is-internal-host? internal-host
|
||||||
collects-hosts collects-dirs
|
collects-hosts collects-dirs
|
||||||
doc-hosts doc-dirs
|
doc-hosts doc-dirs
|
||||||
|
@ -25,11 +25,6 @@
|
||||||
;; URLs.)
|
;; URLs.)
|
||||||
|
|
||||||
(define internal-host "localhost")
|
(define internal-host "localhost")
|
||||||
;; fake an internal-port binding (actually a parameter in options.ss)
|
|
||||||
(define-syntax internal-port*
|
|
||||||
(syntax-id-rules ()
|
|
||||||
[(x . xs) ((internal-port) . xs)]
|
|
||||||
[x (internal-port)]))
|
|
||||||
|
|
||||||
(define (is-internal-host? str)
|
(define (is-internal-host? str)
|
||||||
(member str all-internal-hosts))
|
(member str all-internal-hosts))
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
(define-unit-from-context inst@ setup:plt-installer^)
|
(define-unit-from-context inst@ setup:plt-installer^)
|
||||||
(define-unit-from-context real-tcp@ tcp^)
|
(define-unit-from-context real-tcp@ tcp^)
|
||||||
(define-unit-binding config@ config (import) (export web-config^))
|
(define-unit-binding config@ (make-config) (import) (export web-config^))
|
||||||
|
|
||||||
(define-compound-unit/infer help-desk@
|
(define-compound-unit/infer help-desk@
|
||||||
(import)
|
(import)
|
||||||
|
|
|
@ -27,21 +27,21 @@
|
||||||
(format "~a/html/~a/index.htm" (base-docs-url) manual-name))
|
(format "~a/html/~a/index.htm" (base-docs-url) manual-name))
|
||||||
|
|
||||||
(define (prefix-with-server suffix)
|
(define (prefix-with-server suffix)
|
||||||
(format "http://~a:~a~a" internal-host internal-port suffix))
|
(format "http://~a:~a~a" internal-host (internal-port) suffix))
|
||||||
|
|
||||||
(define results-url-prefix (format "http://~a:~a/servlets/results.ss?" internal-host internal-port))
|
(define results-url-prefix (format "http://~a:~a/servlets/results.ss?" internal-host (internal-port)))
|
||||||
(define flush-manuals-path "/servlets/results.ss?flush=yes")
|
(define flush-manuals-path "/servlets/results.ss?flush=yes")
|
||||||
(define flush-manuals-url (format "http://~a:~a~a" internal-host internal-port flush-manuals-path))
|
(define flush-manuals-url (format "http://~a:~a~a" internal-host (internal-port) flush-manuals-path))
|
||||||
|
|
||||||
|
|
||||||
(define relative-results-url-prefix "/servlets/results.ss?")
|
(define relative-results-url-prefix "/servlets/results.ss?")
|
||||||
|
|
||||||
(define home-page-url (format "http://~a:~a/servlets/home.ss" internal-host internal-port))
|
(define home-page-url (format "http://~a:~a/servlets/home.ss" internal-host (internal-port)))
|
||||||
|
|
||||||
(define (make-missing-manual-url coll name link)
|
(define (make-missing-manual-url coll name link)
|
||||||
(format "http://~a:~a/servlets/missing-manual.ss?manual=~a&name=~a&link=~a"
|
(format "http://~a:~a/servlets/missing-manual.ss?manual=~a&name=~a&link=~a"
|
||||||
internal-host
|
internal-host
|
||||||
internal-port
|
(internal-port)
|
||||||
coll
|
coll
|
||||||
(uri-encode name)
|
(uri-encode name)
|
||||||
(uri-encode link)))
|
(uri-encode link)))
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
(define (gen-tcp-connect raw)
|
(define (gen-tcp-connect raw)
|
||||||
(lambda (hostname-string port)
|
(lambda (hostname-string port)
|
||||||
(if (and (is-internal-host? hostname-string)
|
(if (and (is-internal-host? hostname-string)
|
||||||
(equal? internal-port port))
|
(equal? (internal-port) port))
|
||||||
(let-values ([(req-in req-out) (make-pipe)]
|
(let-values ([(req-in req-out) (make-pipe)]
|
||||||
[(resp-in resp-out) (make-pipe)])
|
[(resp-in resp-out) (make-pipe)])
|
||||||
(parameterize ([current-custodian (make-custodian)])
|
(parameterize ([current-custodian (make-custodian)])
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
(provide (all-defined))
|
(provide (all-defined))
|
||||||
|
|
||||||
(define url-helpdesk-root
|
(define url-helpdesk-root
|
||||||
(string-append
|
(format "http://~a:~a/servlets/" internal-host (internal-port)))
|
||||||
"http://" internal-host ":" (number->string internal-port) "/servlets/"))
|
|
||||||
|
|
||||||
(define url-helpdesk-home (string-append url-helpdesk-root "home.ss"))
|
(define url-helpdesk-home (string-append url-helpdesk-root "home.ss"))
|
||||||
(define url-helpdesk-results (string-append url-helpdesk-root "results.ss"))
|
(define url-helpdesk-results (string-append url-helpdesk-root "results.ss"))
|
||||||
|
@ -65,4 +64,4 @@
|
||||||
(define url-helpdesk-tour (url-home-subpage "tour"))
|
(define url-helpdesk-tour (url-home-subpage "tour"))
|
||||||
(define url-helpdesk-why-drscheme (url-home-subpage "why-drscheme"))
|
(define url-helpdesk-why-drscheme (url-home-subpage "why-drscheme"))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user