1 |
phedex |
1.1 |
import cherrypy
|
2 |
|
|
import datetime
|
3 |
|
|
import logging
|
4 |
|
|
import logging.config
|
5 |
|
|
from ConfigParser import ConfigParser
|
6 |
|
|
|
7 |
|
|
from phedex_monitor.service.data_manager import DataManager
|
8 |
|
|
from phedex_monitor.controller.application_controller import ApplicationController
|
9 |
|
|
|
10 |
|
|
# Create a logger
|
11 |
|
|
logging.config.fileConfig("logging.conf")
|
12 |
|
|
logger = logging.getLogger()
|
13 |
|
|
|
14 |
|
|
# Load the configuration
|
15 |
|
|
logger.info("reading the configuration..")
|
16 |
|
|
conf_parser = ConfigParser()
|
17 |
|
|
conf_parser.read("configuration.ini")
|
18 |
|
|
|
19 |
|
|
# Configure the CherryPy server:
|
20 |
|
|
listen_port = conf_parser.getint("CherryPy", "listen_port")
|
21 |
|
|
server_log_filename = conf_parser.get("CherryPy", "server_log_filename")
|
22 |
|
|
mount_path = conf_parser.get("CherryPy", "mount_path")
|
23 |
|
|
|
24 |
|
|
conf = {"server.socket_port" : listen_port,
|
25 |
|
|
"log.error_file" : server_log_filename}
|
26 |
|
|
cherrypy.config.update(conf)
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
# Instantiate the controller
|
30 |
|
|
logger.info("Instantiating the DataManager.")
|
31 |
|
|
data_manager = DataManager(conf_parser)
|
32 |
|
|
logger.info("instantiating the ApplicationController..")
|
33 |
|
|
controller = ApplicationController(data_manager)
|
34 |
|
|
|
35 |
|
|
# Start the server
|
36 |
|
|
cherrypy.tree.mount(controller, mount_path)
|
37 |
|
|
cherrypy.server.quickstart()
|
38 |
|
|
|
39 |
|
|
cherrypy.engine.start()
|
40 |
|
|
data_manager.kill()
|
41 |
|
|
|