#!/usr/bin/env perl
# OPM main script
#
## This program is open source, licensed under the PostgreSQL License.
# For license terms, see the LICENSE file.
#
# Copyright (C) 2012-2014: Open PostgreSQL Monitoring Development Group

use Mojo::Base -strict;

use File::Basename 'dirname';
use File::Spec::Functions qw(catdir splitdir);

# Check if Mojo is installed
eval 'use Mojolicious::Commands';
die <<EOF if $@;
It looks like you don't have the Mojolicious Framework installed.
Please visit http://mojolicio.us for detailed installation instructions.

EOF

# Source directory has precedence
my @base = (splitdir(dirname(__FILE__)), '..');
my $lib = join('/', @base, 'lib');
-e catdir(@base, 't') ? unshift(@INC, $lib) : push(@INC, $lib);

# Application
$ENV{MOJO_APP} ||= 'OPM';

# Start commands for application
require Mojolicious::Commands;
Mojolicious::Commands->start_app($ENV{MOJO_APP});
