[racket] web server: module servlets

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Sep 23 18:04:58 EDT 2014

On Tue, Sep 23, 2014 at 4:42 PM, George Neuner <gneuner2 at comcast.net> wrote:
> Hi,
>
> I'm using 6.0.1 and I have a couple of questions regarding module
> servlets.  I'm new to the server side of Racket so please be gentle.
>
>
> 1) Is there any way to speed up initial servlet loading?  Even for a
> very simple servlet (does nothing, canned response for testing)
> several seconds elapse before it responds to the browser.  I tried
> compiling it to bytecode with raco, but having the ./compiled/.zo file
> available doesn't seem to make any noticeable difference.  I know the
> bytecode still is JIT'd before execution, but I thought eliminating
> the source compile step would have helped more.
>
> Does a web server require the .zo file to be in a different location
> than ./compiled?  Or does it not deal with bytecode files at all?
>

This is why I recommend that new users use serve/servlet, which is
much faster because it does not use namespaces or live loading.

> 2) Debugging module servlets is a pain due to having to stop/restart
> the server.  Is there some clever way to force the server to unload a
> particular servlet but keep running?
>
> I thought about starting the listener in a thread, but I can't figure
> how to get at either the thread or the custodian from within a
> servlet.  Would listener termination have to be done from a hardcoded
> function at the top level?

Doing this pretty much requires not following my advice in question 1,
but the default server (used by the command line tool) allows you to
go to "/conf/refresh-servlets" and unload/reload all the servlet code.

The way that you would know that is by following the link from the
command-line docs

http://docs.racket-lang.org/web-server/run.html#%28part._command-line-tools%29

to the web-server@ unit which is the implementation of the dispatch
sequence the command-line tool uses:

http://docs.racket-lang.org/web-server-internal/Web_Servers.html#%28def._%28%28lib._web-server%2Fweb-server-unit..rkt%29._web-server~40%29%29

>
> Apologies if these questions are stupid.
>
> Thanks,
> George
>
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



-- 
Jay McCarthy
http://jeapostrophe.github.io

           "Wherefore, be not weary in well-doing,
      for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
                          - D&C 64:33

Posted on the users mailing list.