Re: Beginners Question
Chris Lightfoot <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <0amW7HmQqma/[email protected]> |
On Wed, Jul 12, 2006 at 10:35:30AM -0300, Jose Adriano Baltieri wrote: > Hello members of the list ! > > Our site runs on WebSite http server, that was from OReilly. But this > product has been discontinued. So, I'm thinking about migrating to Apache. > > The problem is that I'm a heavy user of the WebSite API. So, I dont use > CGIs at all. I used it for a while but then I migrated to the WSAPI > (WebSite API). I know, I know, I should NEVER had done that... Sorry ! > I'm paying for this mistake right now... > > Anyway, how does the API work ? > > The basic job implemented via the API is this : dump the http request > into a plain text file (kind of CGI-WIN) on a RAMDRIVE folder. Then, > wait for the answer on the same folder , as a file and read it. > > I have a global counter (integer) that I increase as each request comes > in. Files are named bused on this request number. > > On the other side, of course I have an application that is doing the > real job, that is, the application is watching the folder , processing > and putting the file back. > > There are several folders, because that application is multi-threaded. > > The API is who coordinates or chooses to which folder (or thread) it > will pass the request. So, it "knows" wich thread is available. It also > knows when it's about time to start a new thread or stop old ones. It > also has a queue of requests and several other sophisticated things. > > To do that all, I need global data structures that are accessed amongst > all simultaneous connections (requests). Nowadays, I use critical > sections to avoid conflicts. > > Will I be able to do the same or a similar thing using FASTCGI ? yes, though that's a slightly horrid protocol. Note that you'll have to write a multiplexed or threaded FastCGI server, or have some other synchronisation method, to use the counter scheme you describe -- if it's OK to use some other means to generate a unique number, that might be easier. Basically you need to run in a loop, extracting the headers from the environment variables (e.g. A-Header: becomes $HTTP_A_HEADER in the environment) and printing them to your temporary file, then printing any content from a POST or PUT to it as well, then wait for the response file to be generated. But why not take this opportunity to get rid of the temporary file step, and just incorporate the code that generates those response files into a new FastCGI process? -- ``Unused to the rough and ready answering-back of British socialism, [Kruschev] remarked next day that if he lived in Britain he would be a Tory.'' (Peter Lewis, `The Fifties', on the 1955 visit of Nikita Kruschev to Britain) ___________________________________ fastcgi-developers mailing list http://fastcgi.com/fastcgi-developers/