[racket] Quitting web servlet apps

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Jun 23 16:33:12 EDT 2010

Hi Nadeem,

I'm not sure why curl and the Web browser behave differently. Is it
possible to see a network trace?

As for having a different shutdown URL... I'm curious why you want one
for starters, because there may be a better way to do what you want.

The shutdown URL with serve/servlet works by calling the shutdown
function that serve returns. All that does is kill the custodian that
the server was started with. So, you could do the same thing by
knowing what the server's custodian.

Jay

On Wed, Jun 23, 2010 at 1:36 PM, Nadeem Abdul Hamid <nadeem at acm.org> wrote:
> A couple of questions regarding quitting web apps,
>
> 1. I start up a servlet so:
>    (serve/servlet my-dispatch #:quit? #t ...)
>  Now, how come if I use a program like curl/wget to access the "/quit" URL, the server doesn't shut down, but accessing the same URL via a web browser does? Here's the terminal interaction with curl:
>
> $ curl http://localhost:8000/quit
> <html><head><title>Server Stopped</title><link rel="stylesheet" href="/error.css" /></head><body><div class="section"><div class="title">Server Stopped</div><p>Return to DrRacket.</p></div></body></html>
>
> ... The server continues running. Now if I visit the same url in a browser, it stops after displaying the same HTML above. Here's the log file for the servlet (the two requests look identical):
>
> 127.0.0.1 - - [23/Jun/2010:15:25:29 -0400] "GET /quit HTTP/1.1" 200 512
> 127.0.0.1 - - [23/Jun/2010:15:25:37 -0400] "GET /quit HTTP/1.1" 200 512
>
>
>
> 2. In general, is there a good way to set up a different URL to stop the server? E.g. suppose I want to set up a "/shutdown" URL that determines first if the current user is properly authenticated, and then shuts down the server. I was playing around putting in a request to "/quit" in the handler for the /shutdown URL: "(get-pure-port (string->url "http://localhost:8000/quit")) ... " but this, like with curl, returns the "Server Stopped" page but doesn't actually stop the server.  How does the DrRacket "Stop" button stop a running web server nicely? I tried doing (break-thread (current-thread)) in the handler for /shutdown, but that didn't quit work either.
>
>
> Thanks in advance,
> --- nadeem
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users
>



-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.