[plt-scheme] more questions about plt web server

From: Zhu Chongkai (mathematica at citiz.net)
Date: Fri Jan 14 21:02:51 EST 2005

Please read the "web-server collection" of PLT Help Desk,
especially the "Another Start" section:

Requiring the library _web-server.ss_, via 
  (require (lib "web-server.ss" "web-server"))
provides the serve function, which starts the server with more configuration

> serve : configuration [nat] [str or #f] -> (-> void)

  The serve function starts the Web server, just like the launcher does,
  but the configuration argument supplies the server's settings. 

  The result of invoking serve is a function of no arguments that shuts down
  the server.

> load-configuration : path -> configuration
  This function accepts a path to a configuration file and returns a
  configuration that serve accepts.  The configuration servlet creates
  configuration files.
======= At 2005-01-15, 00:25:29 Larry White wrote: =======

>This looks exactly like what I'm looking for, but I'm not entirely
>getting it.  Does this code actually launch the server?  Is that done
>by calling "serve" after setting up the globals?
>If you have a more complete example handy that would be very helpful.
>thanks alot.
>On Sat, 8 Jan 2005 11:24:07 +0800, Zhu Chongkai <mathematica at citiz.net> wrote:
>>   For list-related administrative tasks:
>>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> ======= At 2005-01-08, 04:42:27 Larry White wrote: =======
>> >  For list-related administrative tasks:
>> >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> >
>> >Hi,
>> >
>> >First, thanks for the help so far.  It's greatly appreciated.   This
>> >is the most fun i've had coding since i got paid to work in smalltalk.
>> >
>> >1. When writing servlets, what do you do with resources that should
>> >have application scope- things like a global hashtable for sessions or
>> >a db connection pool that need to persist across servlets,
>> >continuations, etc.  For the record, i can't use a single servlet with
>> >continuations to represent an entire session with my app because it
>> >would be too large.
>> I once met the same situation as you and managed just by launch the
>> web-server with "global variables".
>> The code looks like:
>> (require (lib "web-server.ss" "web-server"))
>> (define global-variable
>>   #f)
>> ...
>> ;define your global hashtable, db connection pool, or
>> ;anything you want here
>> (define shut-down-the-server
>>   (serve (load-configuration "the-path-of-your-config-file")))
>> And then in you servlets, just access the global-variable you
>> defined. But please note that servlets may be invoked concurrently
>> so you may need semaphore (or some equivalent) if you want to have
>> side-effects on global-variables.
>> I think this approach is easy. And actually, if I want to close the
>> web-server, I can do some thing on the global-variable (such as
>> disconnect to the db) by explict code on it befor or after call
>> (shut-down-the-server).
>> >
>> >2. The smalltalk days referred to above came to an end because our
>> >chosen smalltalk used language threads in such a way that the entire
>> >application blocked on external function calls - like a database
>> >access for example.  Since that was where the web app spent most of
>> >its time, it could only handle one user at a time.  (I hear earlier
>> >versions of python had the same issue.)   Please tell me this isn't
>> >the case with mzscheme.
>> >
>> >Thanks again.
>> >
>> >

= = = = = = = = = = = = = = = = = = = =
Zhu Chongkai
Lambda: Not the Ultimate Solution

Posted on the users mailing list.