Home | Wiki | OI 1.x Docs | OI 2.x Docs OI logo

NAME

HTTP::Daemon::OpenInteract2 - Standalone HTTP daemon for OpenInteract 2

SYNOPSIS

 my $daemon = HTTP::Daemon::OpenInteract2->new(
                  { website_dir => $website_dir });
 print "OpenInteract 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're 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	

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 to simply serve static files beginning with that path under the website's HTML directory. 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 isn't found the client gets a standard 404 message. If the file is found its content type is determined by the routines in OpenInteract2::File.

Entries under 'static_path' should not have any deployment context. For static files the server will respond to the same request off the root context and the deployment context. So if we deployed this application under '/intranet' you'd keep the static path as '/images' and the following would happen (assuming the server was running on 'localhost' port 8080):

 Request                                 Result
 ====================                    ====================
 http://localhost:8080/images            Static file sent
 http://localhost:8080/intranet/images   Static file sent
 http://localhost:8080/bar/images        Non-context request error page

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

HTTP::Daemon

COPYRIGHT

Copyright (c) 2002-2003 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_04 source.


Home | Wiki | OI 1.x Docs | OI 2.x Docs
SourceForge Logo