Esempio n. 1
0
from fiware_cloto.environments import environment_controller
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

import datetime

from django.utils import timezone
from fiware_cloto.cloto.models import ServerInfo
from django.conf import settings
from fiware_cloto.cloto.utils.log import logger

runningfrom = datetime.datetime.now(tz=timezone.get_default_timezone())
# Creating initial data
s = ServerInfo(id=1,
               owner=settings.OWNER,
               version=settings.VERSION,
               runningfrom=runningfrom,
               doc=settings.API_INFO_URL)
try:
    s.save()
except Exception as ex:
    logger.error(
        "Error saving initial server data into DB while server was starting: %s",
        ex)

# Starting environments Controller
controller = environment_controller.environment_controller()
if not controller.is_started():
    controller.start_manager()

logger.info("SERVER STARTED")