Skip to content
Snippets Groups Projects
Commit 8f01ff27 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added support for new Start plugin functionality

parent 86356107
No related branches found
No related tags found
No related merge requests found
...@@ -57,11 +57,9 @@ if (defined($globals->{'config'}->{'background'})) { ...@@ -57,11 +57,9 @@ if (defined($globals->{'config'}->{'background'})) {
} }
displayBanner(); displayBanner();
init(); init();
start();
$logger->log(LOG_NOTICE,"[MAIN] Starting events..."); $logger->log(LOG_NOTICE,"[MAIN] Entering RUNNING state");
POE::Kernel->run(); POE::Kernel->run();
exit; exit;
...@@ -201,21 +199,20 @@ sub init ...@@ -201,21 +199,20 @@ sub init
}, },
); );
$logger->log(LOG_NOTICE,"[MAIN] Entering INITIALIZATION state");
$logger->log(LOG_INFO,"[MAIN] Initializing plugins...");
# Core configuration manager # Core configuration manager
$logger->log(LOG_INFO,"[MAIN] Initializing config manager...");
my $res = eval(" my $res = eval("
use opentrafficshaper::plugins::configmanager; use opentrafficshaper::plugins::configmanager;
plugin_register(\$globals,\"configmanager\",\$opentrafficshaper::plugins::configmanager::pluginInfo); plugin_register(\$globals,\"configmanager\",\$opentrafficshaper::plugins::configmanager::pluginInfo);
"); ");
if ($@ || (defined($res) && $res != 0)) { if ($@ || (defined($res) && $res != 0)) {
$logger->log(LOG_WARN,"[MAIN] Error loading config manager, things WILL BREAK! ($@)"); $logger->log(LOG_WARN,"[MAIN] Error loading config manager, things WILL BREAK! ($@)");
} else {
$logger->log(LOG_DEBUG,"[MAIN] Config manager initialized.");
} }
# Load plugins # Load plugins
$logger->log(LOG_INFO,"[MAIN] Initializing plugins...");
foreach my $plugin (@{$globals->{'config'}->{'plugin_list'}}) { foreach my $plugin (@{$globals->{'config'}->{'plugin_list'}}) {
# Load plugin # Load plugin
my $res = eval(" my $res = eval("
...@@ -255,6 +252,24 @@ sub plugin_register { ...@@ -255,6 +252,24 @@ sub plugin_register {
} }
# Function to start things up
sub start
{
$logger->log(LOG_NOTICE,"[MAIN] Entering STARTING state");
# Loop with plugins and call the start function for those that exist
foreach my $plugin (@{$globals->{'plugins'}})
{
# Load the function up
my $callStart = $plugin->{'Start'};
if (defined($callStart)) {
$callStart->();
}
}
}
# Become daemon # Become daemon
sub daemonize { sub daemonize {
chdir '/' chdir '/'
...@@ -300,8 +315,6 @@ sub main_session_start ...@@ -300,8 +315,6 @@ sub main_session_start
# Register signal handlers # Register signal handlers
$kernel->sig('HUP', 'main_SIGHUP'); $kernel->sig('HUP', 'main_SIGHUP');
$kernel->sig('INT', 'main_SIGINT'); $kernel->sig('INT', 'main_SIGINT');
$logger->log(LOG_INFO,"[MAIN] Started");
} }
# Function to dispose of anything as a final stage to shutting down # Function to dispose of anything as a final stage to shutting down
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment