# frozen_string_literal: true module Legion # Used for creating the actual legion service class Service def initialize(_options = {}) setup_logging Legion::Logging.debug('Starting Legion::Service') setup_settings setup_transport setup_sequel setup_supervision sleep(0.1) load_extensions end def setup_sequel require 'legion/data/connection' Legion::Data::Connection.new Legion::Data::Connection.new Legion::Data::Connection.new @connected = true end def setup_settings require 'legion/settings' Legion::Logging.debug('Loading Legion::Settings') @settings = Legion::Settings.load(config_dir: './settings') Legion::Logging.info('Legion::Settings Loaded') end def setup_logging require 'legion/logging' Legion::Logging.setup(level: 'info') end def setup_transport require 'legion/transport' require 'legion/transport/connection' Legion::Transport::Connection.new end def setup_supervision require 'celluloid/current' Celluloid.logger = Legion::Logging require_relative('supervison') @supervision = Legion::Supervision.new end def shutdown Legion::Logging.info('Legion::Service.shutdown was called') @shutdown = true @supervision.stop_supervision Celluloid.shutdown end def load_extensions require 'legion/runners/runner' require 'legion/extension/loader' Legion::Extension::Loader.new(@supervision).load_extensions end end end