Sha256: b8062671bb883e026ee718825251c2208c3ec775becbbb33a48e56a8e795ed4c

Contents?: true

Size: 690 Bytes

Versions: 5

Compression:

Stored size: 690 Bytes

Contents

require 'drb'
require_relative 'server'

class VagrantFoodtasterServer
  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}", VagrantFoodtasterServer::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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-foodtaster-server-0.0.7 lib/vagrant-foodtaster-server/server_command.rb
vagrant-foodtaster-server-0.0.6 lib/vagrant-foodtaster-server/server_command.rb
vagrant-foodtaster-server-0.0.5 lib/vagrant-foodtaster-server/server_command.rb
vagrant-foodtaster-server-0.0.4 lib/vagrant-foodtaster-server/server_command.rb
vagrant-foodtaster-server-0.0.3 lib/vagrant-foodtaster-server/server_command.rb