2020-11-26 18:58:08 +01:00
|
|
|
from typing import Optional
|
|
|
|
|
2020-11-26 19:17:05 +01:00
|
|
|
from sh_edraft.configuration.base import ConfigurationBase
|
2020-11-26 17:57:51 +01:00
|
|
|
from sh_edraft.hosting import ApplicationHost
|
2020-11-26 18:58:08 +01:00
|
|
|
from sh_edraft.hosting.base import ApplicationBase
|
2020-11-26 19:17:05 +01:00
|
|
|
from sh_edraft.logging import Logger
|
|
|
|
from sh_edraft.logging.base import LoggerBase
|
|
|
|
from sh_edraft.service.base import ServiceProviderBase
|
2020-11-26 17:57:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Program(ApplicationBase):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
ApplicationBase.__init__(self)
|
|
|
|
|
2020-11-26 18:58:08 +01:00
|
|
|
self._app_host: Optional[ApplicationHost] = None
|
|
|
|
|
2020-11-26 19:17:05 +01:00
|
|
|
self._services: Optional[ServiceProviderBase] = None
|
|
|
|
self._configuration: Optional[ConfigurationBase] = None
|
|
|
|
|
2020-11-26 18:58:08 +01:00
|
|
|
def create_application_host(self):
|
2020-11-28 15:13:54 +01:00
|
|
|
self._app_host = ApplicationHost()
|
2020-11-26 19:17:05 +01:00
|
|
|
self._services = self._app_host.services
|
|
|
|
self._configuration = self._app_host.configuration
|
|
|
|
|
2020-11-26 17:57:51 +01:00
|
|
|
def create_configuration(self):
|
2020-11-26 19:17:05 +01:00
|
|
|
self._configuration.create()
|
2020-11-28 15:13:54 +01:00
|
|
|
self._configuration.add_environment_variables('PYTHON_')
|
|
|
|
self._configuration.add_environment_variables('CPL_')
|
|
|
|
self._configuration.add_argument_variables()
|
|
|
|
self._configuration.add_json_file(f'appsettings.json')
|
|
|
|
self._configuration.add_json_file(f'appsettings.{self._configuration.environment.environment_name}.json')
|
|
|
|
self._configuration.add_json_file(f'appsettings.{self._configuration.environment.host_name}.json', optional=True)
|
2020-11-26 17:57:51 +01:00
|
|
|
|
|
|
|
def create_services(self):
|
2020-11-26 19:17:05 +01:00
|
|
|
self._services.create()
|
|
|
|
self._services.add_singleton(LoggerBase, Logger)
|
|
|
|
logger: Logger = self._services.get_service(LoggerBase)
|
|
|
|
logger.create()
|
2020-11-28 15:13:54 +01:00
|
|
|
logger.header(f'{self._configuration.environment.application_name}:')
|
|
|
|
logger.debug(__name__, f'Host: {self._configuration.environment.host_name}')
|
|
|
|
logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
|
|
|
|
logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
|
2020-11-26 17:57:51 +01:00
|
|
|
|
|
|
|
def main(self):
|
|
|
|
print('RUN')
|