class Minicron::Transport::Server

Used to mangage the web server minicron runs on

Attributes

server[RW]

Public Class Methods

running?() click to toggle source

Returns a bool based on whether @return [Boolean]

# File lib/minicron/transport/server.rb, line 64
def self.running?
  return false unless !@server.nil?

  @server.running?
end
start!(host, port, path) click to toggle source

Starts the thin server

@param host [String] the host e.g 0.0.0.0 @param port [Integer] @param path [String] The absolute path to the server e.g /server

# File lib/minicron/transport/server.rb, line 26
def self.start!(host, port, path)
  return false if running?

  # Start the faye or rails apps depending on the path
  @server = Thin::Server.new(host, port) do
    use Rack::CommonLogger
    use Rack::ShowExceptions

    # The 'hub', aka our sinatra web interface
    map path do
      use Minicron::Hub::ExceptionHandling
      run Minicron::Hub::App.new
    end

    # Set the path faye should start relative to
    faye_path = path == '/' ? '/faye' : "#{path}/faye"

    # The faye server the server and browser clients talk to
    map faye_path do
      run Minicron::Transport::FayeServer.new.server
    end
  end

  @server.start
  true
end
stop!() click to toggle source

Stops the thin server if it's running @return [Boolean] whether the server was stopped or not

# File lib/minicron/transport/server.rb, line 55
def self.stop!
  return false unless running? && !@server.nil?

  @server.stop
  true
end