class FTPMVC::Server

Attributes

host[R]
port[R]

Public Class Methods

new(host='0.0.0.0', port) click to toggle source
# File lib/ftpmvc/server.rb, line 9
def initialize(host='0.0.0.0', port)
  @host, @port = host, port
end

Public Instance Methods

start(application) { |self| ... } click to toggle source
# File lib/ftpmvc/server.rb, line 24
def start(application)
  start_in_new_thread(application)
  yield self if block_given?
  @server.join
end
start_in_new_thread(application) click to toggle source
# File lib/ftpmvc/server.rb, line 13
def start_in_new_thread(application)
  driver = Ftpd::Driver.new(application)
  @server = ::Ftpd::FtpServer.new(driver)
  @server.interface, @server.port = @address, @port
  @server.on_exception { |e| application.handle_exception(e) }
  @server.start
  @port = @server.bound_port
  %w{ INT TERM }.each { |sig| Signal.trap(sig) { stop } }
  self
end
stop() click to toggle source
# File lib/ftpmvc/server.rb, line 30
def stop
  @server.stop
end