Sha256: e68fd9a52835dcc354d0e1ce5bb3faf3825fa1991a3fd618d568de7325d36087

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legionio-0.1.1 lib/legion/service.rb