2021-04-07 18:19:34 +02:00
|
|
|
import os
|
|
|
|
|
2021-03-04 06:53:38 +01:00
|
|
|
from cpl_cli.error import Error
|
2021-03-13 11:05:17 +01:00
|
|
|
from cpl_cli.live_server.live_server_service import LiveServerService
|
2021-03-04 19:06:53 +01:00
|
|
|
from cpl_cli.publish.publisher_abc import PublisherABC
|
2022-05-19 18:09:25 +02:00
|
|
|
from cpl_cli.publish.publisher_service import PublisherService
|
|
|
|
from cpl_core.application.startup_abc import StartupABC
|
|
|
|
from cpl_core.configuration.configuration_abc import ConfigurationABC
|
|
|
|
from cpl_core.dependency_injection.service_collection_abc import ServiceCollectionABC
|
|
|
|
from cpl_core.dependency_injection.service_provider_abc import ServiceProviderABC
|
2021-10-03 11:23:17 +02:00
|
|
|
from cpl_core.environment import ApplicationEnvironment
|
2021-03-03 18:37:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Startup(StartupABC):
|
|
|
|
|
2021-10-03 11:23:17 +02:00
|
|
|
def __init__(self):
|
2021-03-19 14:20:57 +01:00
|
|
|
StartupABC.__init__(self)
|
|
|
|
|
2021-10-03 11:23:17 +02:00
|
|
|
def configure_configuration(self, configuration: ConfigurationABC, environment: ApplicationEnvironment) -> ConfigurationABC:
|
|
|
|
environment.set_runtime_directory(os.path.dirname(__file__))
|
|
|
|
configuration.argument_error_function = Error.error
|
2021-03-04 06:53:38 +01:00
|
|
|
|
2021-10-03 11:23:17 +02:00
|
|
|
configuration.add_environment_variables('PYTHON_')
|
|
|
|
configuration.add_environment_variables('CPL_')
|
|
|
|
configuration.add_json_file('appsettings.json', path=environment.runtime_directory, optional=False, output=False)
|
2021-03-03 18:37:54 +01:00
|
|
|
|
2021-10-03 11:23:17 +02:00
|
|
|
return configuration
|
2021-03-03 18:37:54 +01:00
|
|
|
|
2021-10-03 11:23:17 +02:00
|
|
|
def configure_services(self, services: ServiceCollectionABC, environment: ApplicationEnvironment) -> ServiceProviderABC:
|
|
|
|
services.add_transient(PublisherABC, PublisherService)
|
|
|
|
services.add_transient(LiveServerService)
|
2021-03-04 19:06:53 +01:00
|
|
|
|
2021-10-03 11:23:17 +02:00
|
|
|
return services.build_service_provider()
|