BusyBird::Manual::Config::Advanced - advanced topics about configuring BusyBird
BusyBird configuration file ~/.busybird/config.psgi is just a PSGI application script, so you can directly use plackup command to start BusyBird.
~/.busybird/config.psgi
$ 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.
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.
end
builder
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.
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.
busybird
timeline
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.
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.
$BusyBird::Log::Logger
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.
~/.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.
sharedir_path
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.
/usr/local
$ cp -a /usr/local/share/perl/5.14.2/auto/share/dist/BusyBird ~/my_sharedir
Change the content of ~/my_sharedir as you like.
~/my_sharedir
Set sharedir_path parameter in ~/.busybird/config.psgi.
busybird->set_config( sharedir_path => "$ENV{HOME}/my_sharedir" );
Toshio Ito <toshioito [at] cpan.org>
<toshioito [at] cpan.org>
To install BusyBird, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BusyBird
CPAN shell
perl -MCPAN -e shell install BusyBird
For more information on module installation, please visit the detailed CPAN module installation guide.