Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
opentrafficshaper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Francisco Manuel Cardoso
opentrafficshaper
Commits
8f01ff27
Commit
8f01ff27
authored
11 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added support for new Start plugin functionality
parent
86356107
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentrafficshaperd
+24
-11
24 additions, 11 deletions
opentrafficshaperd
with
24 additions
and
11 deletions
opentrafficshaperd
+
24
−
11
View file @
8f01ff27
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment