Class: Raval::App

Inherits:
Object
  • Object
show all
Defined in:
lib/raval/app.rb

Overview

Holds the logic for booting a raval server and configuring the process as required, binding to a port, writing a pid file, etc.

Use it like so:

Raval::App.start(:port => 3000)

Options:

:driver - the driver class that implements persistance
:driver_opts - an optional Hash of options to be passed to the driver
               constructor
:host - the host IP to listen on. [default: 127.0.0.1]
:port - the TCP port to listen on [default: 21]
:pid_file - a path to write the process pid to. Useful for monitoring
:user - the user ID to change the process owner to
:group - the group ID to change the process owner to
:name - an optional name to place in the process description

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ App

Returns a new instance of App.



25
26
27
# File 'lib/raval/app.rb', line 25

def initialize(options = {})
  @options = options
end

Class Method Details

.start(options = {}) ⇒ Object



29
30
31
# File 'lib/raval/app.rb', line 29

def self.start(options = {})
  self.new(options).start
end

Instance Method Details

#startObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/raval/app.rb', line 33

def start
  update_procline

  puts "Starting ftp server on 0.0.0.0:#{port}"
  Raval::Server.supervise(host,port, driver, driver_opts)

  change_gid
  change_uid
  write_pid
  setup_signal_handlers
  sleep # for ever
end