Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
6c3da65d
Commit
6c3da65d
authored
3 months ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Forecaster component:
- Homogeneized code with other components
parent
bb6a9837
No related branches found
No related tags found
3 merge requests
!359
Release TeraFlowSDN 5.0
,
!328
Resolve "(CTTC) Update recommendations to use SocketIO on NBI and E2E Orch components"
,
!286
Resolve "(CTTC) Implement integration test between E2E-IP-Optical SDN Controllers"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/forecaster/service/__main__.py
+19
-16
19 additions, 16 deletions
src/forecaster/service/__main__.py
with
19 additions
and
16 deletions
src/forecaster/service/__main__.py
+
19
−
16
View file @
6c3da65d
...
@@ -16,27 +16,28 @@ import logging, signal, sys, threading
...
@@ -16,27 +16,28 @@ import logging, signal, sys, threading
from
prometheus_client
import
start_http_server
from
prometheus_client
import
start_http_server
from
common.Constants
import
ServiceNameEnum
from
common.Constants
import
ServiceNameEnum
from
common.Settings
import
(
from
common.Settings
import
(
ENVVAR_SUFIX_SERVICE_HOST
,
ENVVAR_SUFIX_SERVICE_PORT_GRPC
,
get_env_var_name
,
get_log_level
,
get_metrics_port
,
ENVVAR_SUFIX_SERVICE_HOST
,
ENVVAR_SUFIX_SERVICE_PORT_GRPC
,
get_env_var_name
,
wait_for_environment_variables
)
get_log_level
,
get_metrics_port
,
wait_for_environment_variables
)
from
.ForecasterService
import
ForecasterService
from
.ForecasterService
import
ForecasterService
terminate
=
threading
.
Event
()
LOGGER
:
logging
.
Logger
=
None
TERMINATE
=
threading
.
Event
()
LOG_LEVEL
=
get_log_level
()
logging
.
basicConfig
(
level
=
LOG_LEVEL
,
format
=
"
[%(asctime)s] %(levelname)s:%(name)s:%(message)s
"
)
logging
.
getLogger
(
'
apscheduler.executors.default
'
).
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
'
apscheduler.scheduler
'
).
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
'
monitoring-client
'
).
setLevel
(
logging
.
WARNING
)
LOGGER
=
logging
.
getLogger
(
__name__
)
def
signal_handler
(
signal
,
frame
):
# pylint: disable=redefined-outer-name
def
signal_handler
(
signal
,
frame
):
# pylint: disable=redefined-outer-name
LOGGER
.
warning
(
'
Terminate signal received
'
)
LOGGER
.
warning
(
'
Terminate signal received
'
)
terminate
.
set
()
TERMINATE
.
set
()
def
main
():
global
LOGGER
# pylint: disable=global-statement
log_level
=
get_log_level
()
logging
.
basicConfig
(
level
=
log_level
,
format
=
"
[%(asctime)s] %(levelname)s:%(name)s:%(message)s
"
)
logging
.
getLogger
(
'
apscheduler.executors.default
'
).
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
'
apscheduler.scheduler
'
).
setLevel
(
logging
.
WARNING
)
logging
.
getLogger
(
'
monitoring-client
'
).
setLevel
(
logging
.
WARNING
)
LOGGER
=
logging
.
getLogger
(
__name__
)
def
main
():
wait_for_environment_variables
([
wait_for_environment_variables
([
get_env_var_name
(
ServiceNameEnum
.
CONTEXT
,
ENVVAR_SUFIX_SERVICE_HOST
),
get_env_var_name
(
ServiceNameEnum
.
CONTEXT
,
ENVVAR_SUFIX_SERVICE_HOST
),
get_env_var_name
(
ServiceNameEnum
.
CONTEXT
,
ENVVAR_SUFIX_SERVICE_PORT_GRPC
),
get_env_var_name
(
ServiceNameEnum
.
CONTEXT
,
ENVVAR_SUFIX_SERVICE_PORT_GRPC
),
...
@@ -53,12 +54,13 @@ def main():
...
@@ -53,12 +54,13 @@ def main():
metrics_port
=
get_metrics_port
()
metrics_port
=
get_metrics_port
()
start_http_server
(
metrics_port
)
start_http_server
(
metrics_port
)
# Starting
Forecaster
service
# Starting service
grpc_service
=
ForecasterService
()
grpc_service
=
ForecasterService
()
grpc_service
.
start
()
grpc_service
.
start
()
LOGGER
.
info
(
'
Running...
'
)
# Wait for Ctrl+C or termination signal
# Wait for Ctrl+C or termination signal
while
not
terminate
.
wait
(
timeout
=
1.0
):
pass
while
not
TERMINATE
.
wait
(
timeout
=
1.0
):
pass
LOGGER
.
info
(
'
Terminating...
'
)
LOGGER
.
info
(
'
Terminating...
'
)
grpc_service
.
stop
()
grpc_service
.
stop
()
...
@@ -66,5 +68,6 @@ def main():
...
@@ -66,5 +68,6 @@ def main():
LOGGER
.
info
(
'
Bye
'
)
LOGGER
.
info
(
'
Bye
'
)
return
0
return
0
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
sys
.
exit
(
main
())
sys
.
exit
(
main
())
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