Sha256: 6d4f50d3d72c56b042d155cc1cbeb2e72173cfeaff7f10cd2f34e80b1eda89b9

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

require 'griffin/server'
require 'griffin/listener'

module Griffin
  module Engine
    class Single
      def self.create(config)
        new(Griffin::Server.new, config)
      end

      def initialize(server, config)
        @server = server
        @config = config
        @listener = Griffin::Listener.new(@config[:bind], @config[:port])
      end

      def run
        @config[:services].each do |s|
          @server.handle(s)
        end

        install_handler

        @server.before_run
        @server.run(@listener.listen)
      end

      def install_handler
        trap('INT') do
          @server.shutdown
        end

        trap('TERM') do
          @server.shutdown
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
griffin-0.1.2 lib/griffin/engine/single.rb
griffin-0.1.1 lib/griffin/engine/single.rb