ClosestStorm / v8cgi

Automatically exported from code.google.com/p/v8cgi
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

RFE: standalone server mode #67

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It _seems_ to me that v8cgi has almost all of the components necessary to 
add a standalone server mode, where a JS-implemented server would listen 
for/dispatch HTTP requests, dispatching v8cgi-aware "active pages" by 
simply executing them.

i think this would greatly simplify testing of v8cgi-based apps, since it 
wouldn't require mucking about with the apache config.

Some of the questions would would need to be answered:

- How to determine what "page" to show when a dir is requested? e.g. 
index.v8cgi?
- Whether to serve (or not) static non-v8cgi JS content (images, css, html 
pages, JS files included via the content page's SCRIPT tags, etc.)
- How to isolate an exception in one connection from shutting down the VM, 
or one connection from leaking resources for the life of the VM (e.g. 
instantiating but not properly destroying bound C++ natives which require a 
dtor call for proper cleanup, e.g. db connection).
- There are certainly others...

On second thought... using one VM to server an arbitrary number of pages 
seems like more problems than it's worth. It might be solvable using a C++ 
server impl which starts a new context for each connection.

Maybe something to consider?

Original issue reported on code.google.com by sgbeal@googlemail.com on 30 Apr 2010 at 1:24

GoogleCodeExporter commented 9 years ago
From what I know, you have precisely described what node.js does :) 

I have always developed v8cgi with Apache in mind, so running a custom js-based 
HTTP
server is might be somewhat problematic. All the questions you posed are 
actually
solved pretty nicely in Apache, so this resembles reinventing the wheel a bit:

- how to determine what "page" to serve: mod_rewrite. In v8cgi, we would need 
our own
similar impl.

- whether to serve static content: default handler. In v8cgi, we would need 
something
similar to http://cz.php.net/manual/en/function.fpassthru.php

- how to isolate exceptions and VM crashes: apache MPM. In v8cgi, we would need 
to
support either forking (this is actually already on TODO) or multithreading.

Original comment by ondrej.zara on 30 Apr 2010 at 1:59

GoogleCodeExporter commented 9 years ago
Good tip - i forgot about node.js :).

About fork: i implemented fork() for SpiderMonkey some years ago... maybe it'll 
be of 
help:

http://spiderape.svn.sourceforge.net/viewvc/spiderape/plugins/SystemFuncs/system
_func
s.cpp?view=markup

(search for "fork(" - it's the last function in the file)

Original comment by sgbeal@googlemail.com on 30 Apr 2010 at 2:13