NAME
BusyBird::Manual::Config::Advanced - advanced topics about configuring BusyBird
DESCRIPTION
Use plackup to Start BusyBird
BusyBird configuration file ~/.busybird/config.psgi is just a PSGI application script, so you can directly use plackup command to start BusyBird.
$ plackup -s Twiggy ~/.busybird/config.psgi
BusyBird needs a PSGI server that supports the non-blocking "delayed response" feature. We recommend to use Twiggy.
In fact, busybird command is a simple front-end for Plack::Runner. plackup command accepts more options than busybird command.
Plack Middlewares
Because ~/.busybird/config.psgi is just a PSGI application script, you can use any Plack middlewares as you like.
To use Plack::Builder with BusyBird, enclose the end statement at the bottom with builder block.
use BusyBird;
use Plack::Builder;
Plack::Builder::builder {
Plack::Builder::enable "AccessLog", format => '%h %l %u %t "%r" %>s %b %{X-Runtime}o';
Plack::Builder::enable "Runtime";
end;
};
end statement returns the PSGI application of BusyBird.
Multiple BusyBird Instances
You can set up multiple BusyBird instances in a single PSGI application. To do that, you have to use BusyBird::Main objects directly, because busybird, timeline and end functions from BusyBird module operate only on the singleton instance.
Here is an example of the complete ~/.busybird/config.psgi file.
use strict;
use warnings;
use utf8;
use BusyBird::Main;
use BusyBird::Main::PSGI qw(create_psgi_app);
use Plack::Builder;
my @busybird = (
BusyBird::Main->new,
BusyBird::Main->new,
);
$busybird[0]->set_config(
time_zone => "+0900"
);
$busybird[0]->timeline("home");
$busybird[1]->set_config(
time_zone => "UTC"
);
$busybird[1]->timeline("another_home");
builder {
enable "AccessLog";
mount "/busybird0" => create_psgi_app($busybird[0]);
mount "/busybird1" => create_psgi_app($busybird[1]);
};
See BusyBird, BusyBird::Main and BusyBird::Main::PSGI for detail.
Customize Logging
Sometimes BusyBird components write log messages when it's necessary.
By default the log messages are printed to STDERR, but you can customize this behavior by setting $BusyBird::Log::Logger variable in ~/.busybird/config.psgi.
use BusyBird::Log;
use Log::Dispatch;
my $log = Log::Dispatch->new(
outputs => [
[
'Syslog',
min_level => 'info',
ident => 'BusyBird'
]
]
);
$BusyBird::Log::Logger = sub {
my ($level, $msg) = @_;
$log->log(level => $level, message => $msg);
};
See BusyBird::Log for detail.
Customize User Interface Completely
~/.busybird/config.psgi let you configure various aspects of BusyBird, but you might want to customize its user interface completely.
To do that, set sharedir_path global config parameter. sharedir_path is the path to the directory containing static files for BusyBird, including HTML templates, JavaScript files and themes.
WARNING: Customizing "share" directory is only for testing purposes. The directory's content may be changed drastically in future releases.
To customize user interface, follow the steps below.
Copy the original "share" directory.
The location of the "share" directory depends on how you installed BusyBird. The example below assumes that you installed it under
/usr/local.$ cp -a /usr/local/share/perl/5.14.2/auto/share/dist/BusyBird ~/my_sharedirChange the content of
~/my_sharediras you like.Set
sharedir_pathparameter in~/.busybird/config.psgi.busybird->set_config( sharedir_path => "$ENV{HOME}/my_sharedir" );
AUTHOR
Toshio Ito <toshioito [at] cpan.org>