Sha256: 547c228401854ee166d385df5296c59ff559f314757d375353bfe16c09a93171

Contents?: true

Size: 657 Bytes

Versions: 2

Compression:

Stored size: 657 Bytes

Contents

require_relative 'server'

module DerailSpecs
  class Boot
    def run
      DerailSpecs.hooks.run(:before_server_start)
      Transaction.begin
      set_exit_hooks!

      Server.new.tap(&:boot)

      if command.present?
        puts "Run: #{command}"
        exit system(command)
      else
        loop { sleep 60 }
      end
    end

    private

    def command
      DerailSpecs.configuration.command
    end

    def set_exit_hooks!
      at_exit do
        Transaction.rollback
        DerailSpecs.hooks.run(:before_server_stop)
      end
      Signal.trap("INT") do
        puts "Exiting derail_specs…"
        exit
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
derail_specs-0.7.0 lib/derail_specs/boot.rb
derail_specs-0.6.1 lib/derail_specs/boot.rb