Not a blog

Corosync, OpenVPN and Wheezy

Use tap devices with OpenVPN when running corosync/pacemaker on wheezy over it. Also transport: udpu.

Ceph, Small Disks and Pgs Stuck Incomplete

When using small disks in a ceph setup you may hit bug #8551 leading to your pgs being stuck in incomplete and your cluster never reaching HEALTH_OK.

Check if your osd weights are zero and reweight them if needed.

Hover Is Looking for You

I moved to Octopress and am no longer actively developing Hover. If you want to take over, contact me by email.

Hover 0.7.3 Available

Besides a couple of minor bugs this release fixes one major bug with php >= 5.4

Warning: Creating default object from empty value in…/wp-content/plugins/hover/hover.php on line 182

Mojolicious and Sprintf Loggin

Don’t want to write things like

app->log->debug("foo $config->{foo} versus ".stat->mtime." seconds");

but rather

app->log->debug("foo %s versus %d seconds", $config->{foo}, stat->mtime);

but Mojo::Log does not support that directly. You could use this:

app->log->debug(sprintf("foo %s  versus %d seconds", $config->{foo}, stat->mtime));

with the downside that sprintf() is called even if the message would not be logged due to your app’s log level being higher than that of the call.

Alternatively you could base your own logger class on Mojo::Log:


package My::Log;
use base Mojo::Log;

sub format {
        my ($self, $level, $format, @parameters) = @_;

        return $self->SUPER::format($level, sprintf($format, @parameters));

package main;

use Mojolicious::Lite;

app->log->error("this string %s printf %s", 'uses', 'stuff');
app->log->warn('decimal: %d hex: %x', 16, 16);
app->log->info('pi: %.2f', 3.14159265359);

And it’s output:

[Wed Feb 27 17:24:34 2013] [error] this string uses printf stuff
[Wed Feb 27 17:24:34 2013] [warn] decimal: 16 hex: 10
[Wed Feb 27 17:24:34 2013] [info] pi: 3.14

Mojolicious Behind Apache With Mod_proxy

This is the only way I got an Mojolicious application to work behind an apache2 web server using mod_proxy.

Setting the base will make sure that your routes match the incoming URLs and that the right URL is used in redirects:

my $base = 'http://localhost:3000/app1';

hook 'before_dispatch' => sub {

When using the style sheet or JavaScript helper a leading slash is important, else the path will be wrong:

%= stylesheet '/css/foo.css'

And this is the apache config snippet:

ProxyPass /app1 http://localhost:3000
ProxyPassReverse /app1 http://localhost:3000/app1

Note the missing /app1 at the end of the ProxyPass line.

The complete Mojolicious code:

#!/usr/bin/env perl
use Mojolicious::Lite;

use Time::HiRes qw/gettimeofday/;

my $base = 'http://localhost:3000/app1';

hook 'before_dispatch' => sub {

under sub {
        shift->stash(now => join('.', gettimeofday()));

get '/' => sub {
        my $self = shift;
} => 'index';

get '/foo' => sub {
        my $self = shift;

get '/redirect' => sub {
        my $self = shift;


@@ foo.html.ep
% layout 'default';
% title 'Foo';

@@ index.html.ep
% layout 'default';
% title 'index';

@@ layouts/default.html.ep
<!DOCTYPE html>
    %= stylesheet '/css/foo.css'
    <title><%= title %></title>
    <h1>Welcome to <%= title %></h1>
    <p>Now: <%= stash('now') %></p>
    <%= content %>
     <li><%= link_to 'Index' => 'index' %></li>
     <li><%= link_to 'Foo' => 'foo' %></li>
     <li><%= link_to 'Redirect' => 'redirect' %>: Will redirect to foo</li>

Mojolicious and Linux::Inotify2

This is a tiny example on how to use Linux::Inotify2 from within a Mojolicious application to watch a file for modification. Note: this will not work with morbo, as no inotify will be delivered to the app. Update: it works with morbo if you use our $io = … instead of my $io = …. The reason for that is, my $io goes out of scope as app->start() does not block.

You will need these modules:

  • Linux::Inotify2 - scalable directory/file change notification

  • EV - perl interface to libev, a high performance full-featured event loop

  • AnyEvent - the DBI of event loop programming

  • And of course Mojolicious

Steps to see the magic happen:

  1. Save the code below to /tmp/i.pl

  2. Create file to be watched: touch /tmp/foo

  3. Run your app (again, morbo will not work): /tmp/i.pl daemon

  4. In another shell, update the watched file: touch /tmp/foo

This is what Mojolicious should log:

[Tue Feb 26 21:22:09 2013] [info] Listening at “http://*:3000”. Server available at [Tue Feb 26 21:22:13 2013] [debug] file changed [Tue Feb 26 21:22:13 2013] [debug] file changed [Tue Feb 26 21:22:13 2013] [debug] file changed



use Mojolicious::Lite;

use Linux::Inotify2;
use EV;
use AnyEvent;

sub file_changed {
        app->log->debug("file changed");

sub setup_notify {
        my $inotify = new Linux::Inotify2;
        $inotify->watch('/tmp/foo', IN_ALL_EVENTS, 

        my $io = AnyEvent->io(
                fh => $inotify->{fd},
                poll => 'r',
                cb => sub { $inotify->poll }

        return $io;

get '/' => sub { shift->render_text('index') };

our $io = setup_notify();


Hover 0.7.2 Available

This release fixes an interoperability issue with the Events Manager plugin. Thanks to Marcus Sykes for helping me narrow down the problem.

Hover 0.7.1 Available

This release fixes undefined constant/variable warnings, an error during checks triggerd by a missing table, the has_cap deprecation warning and a bug where the activation hook may not be run.

Also Maintenance options have been added.