Forked from
opentrafficshaper / opentrafficshaper
219 commits behind the upstream repository.
-
Nigel Kukard authoredNigel Kukard authored
opentrafficshaperd 7.62 KiB
#!/usr/bin/perl
# Main OpenTrafficShaper program
# Copyright (C) 2007-2013, AllWorldIT
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use warnings;
# Set the dirs we look for library files in
use lib('/usr/local/lib/opentrafficshaper-1.0','/usr/lib/opentrafficshaper-1.0',
'/usr/lib64/opentrafficshaper-1.0','opentrafficshaper','awitpt','lib');
# Enable assertions
BEGIN {
package POE::Kernel;
use constant ASSERT_DEFAULT => 1;
}
# System stuff we need
use Config::IniFiles;
use Getopt::Long;
use POE;
use POSIX qw(setsid);
use Time::HiRes qw(time);
# Our own stuff
use opentrafficshaper::version;
use opentrafficshaper::logger;
use opentrafficshaper::plugins qw( plugin_register );
# Main config
my $globals;
# We just create the logger first, its only using STDERR here
my $logger = new opentrafficshaper::logger;
#
# MAIN
#
parseCfgCmdLine();
# Check if we must use a log file instead
if (defined($globals->{'config'}->{'log_file'})) {
$logger->open($globals->{'config'}->{'log_file'});
}
$logger->setLevel($globals->{'config'}->{'log_level'});
# Check if we need to go background
if (defined($globals->{'config'}->{'background'})) {
daemonize();
}
displayBanner();
init();
start();
$logger->log(LOG_NOTICE,"[MAIN] Entering RUNNING state");
POE::Kernel->run();