Baldrick-stub
From CunningPlans
baldrick-stub is the loader for a Baldrick application running under the CGI interface.
It is not used for a mod_perl. The entry point for a mod_perl invocation of Baldrick is the Baldrick::Trousers class.
baldrick-stub should be copied into your CGI directory, or a subdirectory thereof, and copied or linked to every filename that you want Baldrick to handle.
Essentially, it is the main() of a Baldrick application. baldrick-stub's purpose is to load the Baldrick libraries, create a Baldrick::App object, and turn control over to that App. It also displays error messages if any of these steps fail.
A minimalist baldrick-stub appears at the end of this article, for convenience. The one included in the distribution archive is to be preferred, however, as it adds error handling.
[edit] Installing Baldrick::Stub
baldrick-stub may be found in the "scripts" directory of the distribution archive. It should be copied into your cgi-bin directory.
For example, if your Apache configuration contains this directive:
ScriptAlias /bin /var/www/example.com/cgi-bin
and you want these URLs to be handled by Baldrick:
/bin/shop /bin/chat /bin/forum
then you would perform these steps:
# (from wherever you unpacked Baldrick-0.XX.tgz:) ## Install baldrick-stub. $ cp scripts/baldrick-stub /var/www/example.com/cgi-bin $ cd /var/www/example.com/cgi-bin $ chmod +x baldrick-stub # make it executable ## Make aliases $ ln -s baldrick-stub shop # make aliases for it so the web server can find it. $ ln -s baldrick-stub chat $ ln -s baldrick-stub forum
(Don't have shell access? Just FTP a copy of baldrick-stub to each of these locations).
[edit] Baldrick Library Location
- Main Article: File layout
The baldrick-stub, as shipped, assumes that you have a "lib" directory within your cgi-bin directory, and that the Baldrick perl modules have been installed there (under lib/Baldrick/ ), and that your own application's code will also be in "lib".
If this is not the case, edit baldrick-stub and change the "use lib" statement to point to the proper directory.
[edit] Minimalist baldrick-stub source
One possible baldrick-stub script (much shorter than the one in the distribution package):
#!/usr/bin/perl use lib 'lib'; # where to find the Baldrick libraries - edit this. use Baldrick::Baldrick; # load Baldrick::* libraries new Baldrick::App()->run(); # create an App object and let it do its thing.
The current version, however, is a bit more complex - it does the same three steps, but handles errors better.
