NAME
HTTP::Daemon::OpenInteract2 - Standalone HTTP daemon for OpenInteract 2
SYNOPSIS
my $daemon = HTTP::Daemon::OpenInteract2->new(
{ website_dir => $website_dir });
print "OpenInteract2 now running at URL '", $daemon->url, "'\n";
while (1) {
my $client = $daemon->accept;
next unless ( $client );
my $child = fork();
unless ( defined $child ) {
die "Cannot fork child: $!\n";
}
if ( $child == 0 ) {
$daemon->interact( $client );
$daemon->close;
exit(0);
}
$client->close();
}
$daemon->run;
DESCRIPTION
This module uses HTTP::Daemon to implement a standalone web server running OpenInteract 2. Once it's started you shouldn't be able to tell the difference between its OpenInteract or the same application running on Apache, Apache2, or CGI -- it will have the same users, hit the same database, manipulate the same packages, etc.
The daemon will respect the application deployment context if specified in the server configuration. Any request outside the context will generate a simple error page explaining that it cannot be served.
Performance note: this daemon will not win any speed contests. It will work fine for a handful of users, but if you are seriously deploying an application you should look strongly at Apache and mod_perl.
CONFIGURATION
The configuration file is a simple INI file. Here's an example:
[socket] LocalAddr = localhost LocalPort = 8080 Proto = tcp [content] static_path = ^/images static_path = \.(css|pdf|gz|zip|jpg|gif|png)$
The entries under 'socket' are passed without modification to the constructor for HTTP::Daemon, so if you have specialized needs related to the network consult that documentation.
Currently only one item is supported in 'content': 'static_path'. Each
declaration tells the daemon that if the request URL matches the
regular expression to serve the file under the website HTML directory
directly rather than hitting OpenInteract2. For instance, in the given
configuration the requested path: /images/oi_logo.gif will cause
the daemon to look for the file:
/path/to/mysite/html/images/oi_logo.gif
and serve it as-is to the client. If the file is not found the client gets a standard 404 message. If the file is found its content type is determined by the routines in OpenInteract2::File.
If you define a deployment context (e.g., '/intranet') you may need to modify entries under 'static_path' to match. So if we deployed this application under '/intranet' you would need to change the static path '^/images' to '^/intranet/images'. keep the static path as '/images'.
You can have as many static path declarations as needed.
Tracking Running Server
The parent server stores its process ID (pid) in a file at
startup. This file is called oi2.pid and is stored in the same
directory where the daemon configuration file is kept. You can also
access the filename from the daemon object (pid_file) as well as
the pid (pid).
SEE ALSO
COPYRIGHT
Copyright (c) 2002-2005 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHORS
Chris Winters <chris@cwinters.com>
Generated from the OpenInteract 1.99_06 source.
