Sha256: 005ab744b542a7407d9c6f18f4a00070473c7fe815e587c88cee289d5807bbce

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

require 'drb'
require_relative 'server'

module Vagrant
  module Foodtaster
    module Server
      class ServerCommand < Vagrant.plugin(2, :command)
        def execute
          argv = parse_options

          port_number = argv.size == 0 ? 35672 : argv[0].to_i
          DRb.start_service "druby://localhost:#{port_number}", Vagrant::Foodtaster::Server::Server.new(@app, @env)
          DRb.thread.join

        rescue RuntimeError, Errno::EADDRINUSE => e
          write_formatted_exception_message(e)
        rescue Interrupt
          DRb.stop_service
        end

        private

        def write_formatted_exception_message(e)
          error = "#{e.message}\n\nServer Error Backtrace:\n  #{e.backtrace.join("\n  ")}"
          @env.ui.error(error)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-foodtaster-server-0.0.8 lib/vagrant-foodtaster-server/server_command.rb