Adding collect-garbage
svn: r653
This commit is contained in:
parent
99c49a9c5c
commit
6e1a28e126
|
@ -20,7 +20,8 @@
|
|||
; response
|
||||
; response
|
||||
; (url -> response)
|
||||
; response
|
||||
; response)
|
||||
(provide-define-struct
|
||||
responders
|
||||
(servlet servlet-loading authentication servlets-refreshed passwords-refreshed file-not-found protocol)))
|
||||
(servlet servlet-loading authentication servlets-refreshed passwords-refreshed file-not-found protocol collect-garbage)))
|
||||
|
|
|
@ -6,25 +6,36 @@
|
|||
(default-indices "index.html" "index.htm")
|
||||
(log-format parenthesized-default)
|
||||
(messages
|
||||
(servlet-message "servlet-error.html")
|
||||
(authentication-message "forbidden.html")
|
||||
(servlets-refreshed "servlet-refresh.html")
|
||||
(passwords-refreshed "passwords-refresh.html")
|
||||
(file-not-found-message "not-found.html")
|
||||
(protocol-message "protocol-error.html"))
|
||||
(servlet-message
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/conf/servlet-error.html")
|
||||
(authentication-message
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/conf/forbidden.html")
|
||||
(servlets-refreshed
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/conf/servlet-refresh.html")
|
||||
(passwords-refreshed
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/conf/passwords-refresh.html")
|
||||
(file-not-found-message
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/conf/not-found.html")
|
||||
(protocol-message
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/conf/protocol-error.html")
|
||||
(collect-garbage
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/conf/collect-garbage.html"))
|
||||
(timeouts
|
||||
(default-servlet-timeout 120)
|
||||
;(default-servlet-timeout 300)
|
||||
;(default-servlet-timeout 10)
|
||||
(password-connection-timeout 300)
|
||||
(servlet-connection-timeout 86400)
|
||||
(default-servlet-timeout 120)
|
||||
(password-connection-timeout 300)
|
||||
(servlet-connection-timeout 86400)
|
||||
(file-per-byte-connection-timeout 1/20)
|
||||
(file-base-connection-timeout 30))
|
||||
(paths
|
||||
(configuration-root "conf")
|
||||
(host-root "default-web-root")
|
||||
(log-file-path "log")
|
||||
(file-root "htdocs")
|
||||
(servlet-root ".")
|
||||
(password-authentication "passwords"))))
|
||||
(host-root
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root")
|
||||
(log-file-path
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/log")
|
||||
(file-root
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/htdocs")
|
||||
(servlet-root
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/.")
|
||||
(password-authentication
|
||||
"/Users/jay/Development/plt/src/plt/trunk/collects/web-server/default-web-root/passwords"))))
|
||||
(virtual-host-table))
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
; messages = (make-messages str^6)
|
||||
(provide-define-struct messages
|
||||
(servlet ;servlet-loading
|
||||
authentication servlets-refreshed passwords-refreshed file-not-found protocol))
|
||||
authentication servlets-refreshed passwords-refreshed file-not-found protocol collect-garbage))
|
||||
|
||||
; timeouts = (make-timeouts nat^5)
|
||||
(provide-define-struct timeouts (default-servlet password servlet-connection file-per-byte file-base))
|
||||
|
|
|
@ -225,6 +225,11 @@
|
|||
(define (gen-file-not-found-responder file-not-found-file)
|
||||
(lambda (url)
|
||||
(error-response 404 "File not found" file-not-found-file)))
|
||||
|
||||
; gen-collect-garbage-responder : str -> -> response
|
||||
(define (gen-collect-garbage-responder file)
|
||||
(lambda ()
|
||||
(error-response 200 "Garbage collectedd" file)))
|
||||
|
||||
(define servlet?
|
||||
(let ([servlets-regexp (regexp "^/servlets/.*")])
|
||||
|
@ -290,7 +295,8 @@
|
|||
(gen-servlets-refreshed (build-path-unless-absolute conf (messages-servlets-refreshed m)))
|
||||
(gen-passwords-refreshed (build-path-unless-absolute conf (messages-passwords-refreshed m)))
|
||||
(gen-file-not-found-responder (build-path-unless-absolute conf (messages-file-not-found m)))
|
||||
(gen-protocol-responder (build-path-unless-absolute conf (messages-protocol m)))))
|
||||
(gen-protocol-responder (build-path-unless-absolute conf (messages-protocol m)))
|
||||
(gen-collect-garbage-responder (build-path-unless-absolute conf (messages-collect-garbage m)))))
|
||||
(host-table-timeouts host-table)
|
||||
paths)))
|
||||
|
||||
|
|
|
@ -447,6 +447,8 @@
|
|||
(build-path-unless-absolute conf (messages-file-not-found m)))
|
||||
,(make-tr-str "Protocol error" 'path-protocol-message
|
||||
(build-path-unless-absolute conf (messages-protocol m)))
|
||||
,(make-tr-str "Collect garbage" 'path-collect-garbage-message
|
||||
(build-path-unless-absolute conf (messages-collect-garbage m)))
|
||||
(tr (td ([colspan "2"]) (hr)))
|
||||
(tr (th ([colspan "2"]) "Timeout Seconds"))
|
||||
,(make-tr-num "Default Servlet" 'time-default-servlet (timeouts-default-servlet timeouts))
|
||||
|
@ -473,7 +475,7 @@
|
|||
(host-table-indices old)
|
||||
(host-table-log-format old)
|
||||
(apply make-messages
|
||||
(map eb-conf '(path-servlet-message path-access-message servlet-refresh-message password-refresh-message path-not-found-message path-protocol-message)))
|
||||
(map eb-conf '(path-servlet-message path-access-message servlet-refresh-message password-refresh-message path-not-found-message path-protocol-message path-collect-garbage-message)))
|
||||
(apply make-timeouts
|
||||
(map (lambda (tag) (string->number (extract-binding/single tag bindings)))
|
||||
'(time-default-servlet time-password time-servlet-connection time-file-per-byte time-file-base)))
|
||||
|
@ -731,7 +733,8 @@
|
|||
(copy-conf "forbidden.html" (messages-authentication messages))
|
||||
(copy-conf "protocol-error.html" (messages-protocol messages))
|
||||
(copy-conf "not-found.html" (messages-file-not-found messages))
|
||||
(copy-conf "servlet-error.html" (messages-servlet messages)))))
|
||||
(copy-conf "servlet-error.html" (messages-servlet messages))
|
||||
(copy-conf "collect-garbage.html" (messages-collect-garbage messages)))))
|
||||
|
||||
; ensure-file : path path path -> void
|
||||
; to copy (build-path from name) to (build-path to name), creating directories as
|
||||
|
@ -806,7 +809,8 @@
|
|||
(servlets-refreshed ,(messages-servlets-refreshed m))
|
||||
(passwords-refreshed ,(messages-passwords-refreshed m))
|
||||
(file-not-found-message ,(messages-file-not-found m))
|
||||
(protocol-message ,(messages-protocol m)))
|
||||
(protocol-message ,(messages-protocol m))
|
||||
(collect-garbage ,(messages-collect-garbage m)))
|
||||
(timeouts
|
||||
(default-servlet-timeout ,(timeouts-default-servlet t))
|
||||
(password-connection-timeout ,(timeouts-password t))
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head><title>Garbage Collect Ran</title></head>
|
||||
<body bgcolor='white'>
|
||||
<p>The garbage collection routine has run.</p>
|
||||
<p>Powered by <a href="http://www.plt-scheme.org/">PLT</a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1 +1 @@
|
|||
<html><head><title>Web Server Monitoring</title></head><body bgcolor="white"><img src="/Defaults/documentation/web-server.gif" width="61" height="57" /><h2>Web Server Monitoring</h2><p>The Web server collection provides a program for monitoring Web servers. It periodically checks that a server responds to requests.To use the tool, start the <code>web-server-monitor</code> launcher as follows: </p><blockquote><code>web-server-monitor</code> alert-email host-name [port] [poll-frequency-seconds] [server-response-timeout-seconds]</blockquote><p>The monitor will send a HTTP HEAD request to the server at <code>host-name</code> on port <code>port</code> (or 80) every <code>poll-frequency-seconds</code> seconds (or 1 hour). If the server does not respond within <code>server-response-timeout-seconds</code> (or 75) seconds then the monitor will email <code>alert-email</code> about the problem. Also, if the Web server responds with an error, the monitor will email the error message to <code>alert-email</code>. For example, the following monitors the Web server for the book ``How to Design Programs''</p><blockquote><code>web-server-monitor ptg www.htdp.org</code></blockquote><p>On UNIX systems, it is usually a good idea to redirect standard in, out, and error to <code>/dev/null</code> so the monitor will not quit due to a <code>SIGHUP</code> (hangup signal) when you log out. i.e.</p><blockquote><code>web-server-monitor ptg www.htdp.org > /dev/null < /dev/null 2>&1 &</code></blockquote><p>Powered by <a href="http://www.plt-scheme.org/"><img width="53" height="19" src="/Defaults/documentation/plt-logo.gif" /></a></p></body></html>
|
||||
<html><head><title>Web Server Monitoring</title></head><body bgcolor="white"><img src="/Defaults/documentation/web-server.gif" width="61" height="57" /><h2>Web Server Monitoring</h2><p>The Web server collection provides a program for monitoring Web servers. It periodically checks that a server responds to requests.To use the tool, start the <code>web-server-monitor</code> launcher as follows: </p><blockquote><code>web-server-monitor</code> alert-email host-name [port] [poll-frequency-seconds] [server-response-timeout-seconds]</blockquote><p>The monitor will send a HTTP HEAD request to the server at <code>host-name</code> on port <code>port</code> (or 80) every <code>poll-frequency-seconds</code> seconds (or 1 hour). If the server does not respond within <code>server-response-timeout-seconds</code> (or 75) seconds then the monitor will email <code>alert-email</code> about the problem. Also, if the Web server responds with an error, the monitor will email the error message to <code>alert-email</code>. For example, the following monitors the Web server for the book ``How to Design Programs''</p><blockquote><code>web-server-monitor jay www.htdp.org</code></blockquote><p>On UNIX systems, it is usually a good idea to redirect standard in, out, and error to <code>/dev/null</code> so the monitor will not quit due to a <code>SIGHUP</code> (hangup signal) when you log out. i.e.</p><blockquote><code>web-server-monitor jay www.htdp.org > /dev/null < /dev/null 2>&1 &</code></blockquote><p>Powered by <a href="http://www.plt-scheme.org/"><img width="53" height="19" src="/Defaults/documentation/plt-logo.gif" /></a></p></body></html>
|
||||
|
|
|
@ -27,4 +27,8 @@ the <code>servlet^</code> signature consisting of the following imports:</p><ul>
|
|||
<ul><li><code>send/finish : Response -></code> doesn't return <br />This provides a convenient way to report an error or otherwise produce a final response. Once called, all URLs generated by send/suspend become invalid. Calling send/finish allows the system to reclaim resources consumed by the servlet.</li><li><code>adjust-timeout! : Nat -> Void</code><br />
|
||||
The server will shutdown each instance of a servlet after an unspecified default amount of time since the last time that servlet instance handled a request. Calling adjust-timeout! allows programmers to choose this number of seconds. Larger numbers consume more resources
|
||||
while smaller numbers force servlet users to restart computations more often.
|
||||
</li></ul><p>The <code>servlet-helpers</code> module, required with <blockquote><code>(require (lib "servlet-helpers.ss" "web-server"))</code></blockquote> provides a few additional functions helpful for constructing servlets: <ul><li><code>extract-binding/single : sym (listof (cons sym str)) -> str</code>This extracts a single value associated with sym in the form bindings. If multiple or zero values are associated with the name, it raises an exception.</li><li>extract-bindings : sym (listof (cons sym str)) -> (listof str)returns a list of values assocaited with the name sym.</li><li><code>extract-user-pass : (listof (cons sym str)) -> (U #f (cons str str))</code><br /><code>(define (extract-user-pass headers) ...)</code>Servlets may easily implement password based authentication by extracting password information from the HTTP headers. The return value is either a pair consisting of the username and password from the headers or #f if no password was provided.</li></ul></p><h3>Special URLs</h3><p>The Web server caches passwords and servlets for performance reasons. Requesting the URL<blockquote><a href="/conf/refresh-passwords"><code>http://my-host/conf/refresh-passwords</code></a></blockquote>reloads the password file. After updating a servlet, loading the URL <blockquote><a href="/conf/refresh-servlets"><code>http://my-host/conf/refresh-servlets</code></a></blockquote>causes the server to reload each servlet on the next invocation. This loses any per-servlet state (not per servlet instance state) computed before the unit invocation.</p><p><a href="servlet-examples.html">Examples of Servlets</a></p><p>Powered by <a href="http://www.plt-scheme.org/"><img width="53" height="19" src="/Defaults/documentation/plt-logo.gif" /></a></p></body></html>
|
||||
</li></ul><p>The <code>servlet-helpers</code> module, required with <blockquote><code>(require (lib "servlet-helpers.ss" "web-server"))</code></blockquote> provides a few additional functions helpful for constructing servlets: <ul><li><code>extract-binding/single : sym (listof (cons sym str)) -> str</code>This extracts a single value associated with sym in the form bindings. If multiple or zero values are associated with the name, it raises an exception.</li><li>extract-bindings : sym (listof (cons sym str)) -> (listof str)returns a list of values assocaited with the name sym.</li><li><code>extract-user-pass : (listof (cons sym str)) -> (U #f (cons str str))</code><br /><code>(define (extract-user-pass headers) ...)</code>Servlets may easily implement password based authentication by extracting password information from the HTTP headers. The return value is either a pair consisting of the username and password from the headers or #f if no password was provided.</li></ul></p><h3>Special URLs</h3><p>The Web server caches passwords and servlets for performance reasons. Requesting the URL<blockquote><a href="/conf/refresh-passwords"><code>http://my-host/conf/refresh-passwords</code></a></blockquote>reloads the password file. After updating a servlet, loading the URL <blockquote><a href="/conf/refresh-servlets"><code>http://my-host/conf/refresh-servlets</code></a></blockquote>causes the server to reload each servlet on the next invocation. This loses any per-servlet state (not per servlet instance state) computed before the unit invocation.</p>
|
||||
|
||||
<p>The Web server's garbage collect may be invoked at the URL: <blockquote><a href="/conf/collect-garbage"><code>http://my-host/conf/collect-garbage</code></a></blockquote></p>
|
||||
|
||||
<p><a href="servlet-examples.html">Examples of Servlets</a></p><p>Powered by <a href="http://www.plt-scheme.org/"><img width="53" height="19" src="/Defaults/documentation/plt-logo.gif" /></a></p></body></html>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<html><head><title>Welcome to the PLT Web Server!</title></head><body bgcolor="white"><img src="/Defaults/documentation/web-server.gif" width="61" height="57" /><h2>Welcome to the PLT Web Server!</h2><p>To start using the Web Server, follow these steps:</p><dl><dt><b><a href="documentation/install.html">Installation</a></b></dt><dd>You can skip the install instructions if you are reading this through the PLT Web server.<p /></dd><dt><b><a href="/servlets/configure.ss">Customization</a></b></dt><dd>Use the online configuration tool to customize the server.<p /></dd><dt><b><a href="documentation/servlet.html">Servlet Interface</a></b></dt><dd>Learn how to write Scheme Servlets.<p /></dd><dt><b><a href="documentation/api.html">Embedding Interface</a></b></dt><dd>Embed the Web server in other applications.<p /></dd><dt><b><a href="documentation/monitor.html">Monitoring</a></b></dt><dd>Periodically check that Web servers continue to function.<p /></dd></dl><p>If you use the PLT Web server, please let us know at
|
||||
<a href="mailto:ptg@acm.org"><code>ptg@acm.org</code></a>.</p><p>Powered by <a href="http://www.plt-scheme.org/"><img width="53" height="19" src="/Defaults/documentation/plt-logo.gif" /></a></p></body></html>
|
||||
<a href="mailto:jay@plt-scheme.org"><code>jay@plt-scheme.org</code></a>.</p><p>Powered by <a href="http://www.plt-scheme.org/"><img width="53" height="19" src="/Defaults/documentation/plt-logo.gif" /></a></p></body></html>
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
(servlets-refreshed ,servlets-refreshed)
|
||||
(passwords-refreshed ,passwords-refreshed)
|
||||
(file-not-found-message ,file-not-found-message)
|
||||
(protocol-message ,protocol-message))
|
||||
(protocol-message ,protocol-message)
|
||||
(collect-garbage ,collect-garbage))
|
||||
(timeouts
|
||||
(default-servlet-timeout ,default-servlet-timeout)
|
||||
(password-connection-timeout ,password-connection-timeout)
|
||||
|
@ -60,7 +61,8 @@
|
|||
servlets-refreshed
|
||||
passwords-refreshed
|
||||
file-not-found-message
|
||||
protocol-message)
|
||||
protocol-message
|
||||
collect-garbage)
|
||||
(make-timeouts default-servlet-timeout
|
||||
password-connection-timeout
|
||||
servlet-connection-timeout
|
||||
|
|
|
@ -167,6 +167,12 @@
|
|||
conn
|
||||
((responders-passwords-refreshed (host-responders host-info)))
|
||||
method)]
|
||||
[(string=? "/conf/collect-garbage" path)
|
||||
(collect-garbage)
|
||||
(output-response/method
|
||||
conn
|
||||
((responders-collect-garbage (host-responders host-info)))
|
||||
method)]
|
||||
[else
|
||||
(output-response/method
|
||||
conn
|
||||
|
|
Loading…
Reference in New Issue
Block a user