NAME
Mojolicious::Plugin::Narada - Narada configuration plugin
SYNOPSIS
# Mojolicious
$self->plugin('Narada');
$self->plugin(Narada => (log => Log::Fast->global));
# Mojolicious::Lite
plugin 'Narada';
plugin Narada => (log => Log::Fast->global);
# Global timer
package MyApp;
sub startup {
my $app = shift;
Mojo::IOLoop->timer(0 => $app->proxy(sub { say 'Next tick.' }));
}
# Request-related timer
package MyApp::MyController;
sub myaction {
my $c = shift;
$c->render_later;
Mojo::IOLoop->timer(2 => $c->proxy(sub {
$c->render(text => 'Delayed by 2 seconds!');
}));
}
DESCRIPTION
Mojolicious::Plugin::Narada is a plugin that configure Mojolicious to work in Narada project management environment.
Also this plugin add helper proxy
, and you MUST use it to wrap all callbacks you setup for handling delayed events like timers or I/O (both global in your app and related to requests in your actions).
There is also one feature unrelated to Narada - if callback started by any action throw unhandled exception it will be sent to browser using same $c->reply->exception
as it already works for actions without delayed response.
- Logging
-
Mojolicious default Mojo::Log replaced with MojoX::Log::Fast to support logging to project-local syslog daemon in addition to files. In most cases it works as drop-in replacement and doesn't require any modifications in user code.
Also it set
$app->log->ident()
to$c->req->url->path
to ease log file analyse. - Configuration
-
You should manually add these lines to
./you_app
starting script before call toMojolicious::Commands->start_app()
:use Narada::Config qw( get_config_line ); # mode should be set here because it's used before executing MyApp::startup() local $ENV{MOJO_MODE} = get_config_line('mode');
Config file
config/cookie.secret
automatically loaded and used to initialize$app->secrets()
(each line of file became separate param).Config file
config/basepath
automatically loaded and used to fix$c->req->url->base->path
and$c->req->url->path
to guarantee their consistency in any environment:url->path doesn't contain base->path
url->path does have leading slash
url->base->path set to content of config/basepath
These config files automatically loaded from
config/hypnotoad/*
and used to initialize$app->config(hypnotoad)
:listen proxy accepts workers
Also hypnotoad configured to keep it lock/pid files in
var/
. - Locking
-
unlock()
will be automatically called after all actions and callbacks, even if they throw unhandled exception.
OPTIONS
Mojolicious::Plugin::Narada supports the following options.
log
plugin Narada => (log => Log::Fast->global);
Value for MojoX::Log::Fast->new().
METHODS
Mojolicious::Plugin::Narada inherits all methods from Mojolicious::Plugin and implements the following new ones.
register
$plugin->register(Mojolicious->new);
$plugin->register(Mojolicious->new, {log => Log::Fast->global});
Register hooks in Mojolicious application.
SEE ALSO
Narada, MojoX::Log::Fast, Mojolicious.
BUGS AND LIMITATIONS
No bugs have been reported.
SUPPORT
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Plugin-Narada. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mojolicious-Plugin-Narada
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
AUTHOR
Alex Efros <powerman@cpan.org>
LICENSE AND COPYRIGHT
Copyright 2013,2014 Alex Efros <powerman@cpan.org>.
This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.