question about using the built-in web server

Per Bothner per@bothner.com
Thu May 10 08:22:00 GMT 2012


On 05/09/2012 08:35 PM, alex mitchell wrote:
> So, what I'm thinking of doing is using the built-in web server in Kawa to
> serve up the Javascript story file locally, and then have debugging
> functions within the Javascript code pass state information back to the
> server, and from there display the state info in the editor UI. What I'm
> not sure about is a) whether it is possible to simultaneously run the web
> server and have an interactive UI, and b) whether the web server and the
> UI code can communicate.
>
> So far, I've tried a simple experiment by doing:
>      kawa --http-auto-handler / . --http-start 8888 mycode.scm
> where mycode.scm is
>      (display "hi\n")
> and although the web server starts, and is accessible at port 8888,
> mycode.scm is never executed. This suggests that a) may not be possible.

This is because the "--http-start" sets the _something_done flag, which
supresses trying loading mycode.scm.

You could try:
   kawa --http-auto-handler / . -e 
'(gnu.kawa.servlet.KawaHttpHandler:startServer 8888)' mycode.scm

However, I'm guessing this may have threading issues.  You probably want 
to run
the server in a separate thread.  Perhaps making use of 
HttpServer#setExecutor
is needed, in which case we would need to make that calling from
KawaHttpHandler.

> I suppose one approach might be to start the web server as a separate
> process, and then have the editor and the web server communicate through
> sockets, but that seems a bit troublesome.

Using a separate thread is probably enough - but you still have to
make sure the communication is thread-safe and non-blocking.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



More information about the Kawa mailing list