Reworking the Puma server integration

This commit is contained in:
Chris Cowan 2014-08-28 17:16:06 -07:00
parent c678bbc7f1
commit 1804dfe2ac
2 changed files with 37 additions and 10 deletions

View file

@ -24,6 +24,9 @@ parser = OptionParser.new do |opts|
opts.on('-p', '--port PORT', 'Kibana port') do |arg|
options[:port] = arg
end
opts.on('-H', '--host HOST', 'Kibana host') do |arg|
options[:host] = arg
end
opts.on('-v', '--version', 'Display version') do |arg|
puts ENV['KIBANA_VERSION'] || 'dev-build'
exit
@ -46,6 +49,9 @@ config = YAML.load(IO.read(options[:config]))
# Set the override for the port
port = (options[:port] || config['port'])
# Set the override for the host
host = (options[:host] || config['host'])
# Set the override for Elasticsaerch
elasticsearch = (options[:elasticsearch] || config['elasticsearch'])
@ -55,14 +61,26 @@ ENV["KIBANA_CONFIG_FILE"] = options[:config]
ENV["KIBANA_ELASTICSEARCH"] = elasticsearch
# Clone argv and then clear it and set up the defaults for the Puma CLI
puma_args = ARGV.clone()
puma_args.clear
puma_args << '--port'
puma_args << port.to_s
puma_args << "#{HERE}/../config/web.ru"
# puma_args = ARGV.clone()
# puma_args.clear
# puma_args << '--tag'
# puma_args << 'kibana'
# puma_args << '-d'
# puma_args << '--port'
# puma_args << port.to_s
# puma_args << "#{HERE}/../config/web.ru"
# gem 'puma', version
# load Gem.bin_path('puma', 'puma', version)
#
cli = Puma::CLI.new puma_args
cli.run
# cli = Puma::CLI.new puma_args
# cli.run
require "#{HERE}/../lib/server"
server_opts = {
:port => port || 5601,
:host => host || '0.0.0.0'
}
Kibana::Server.run(server_opts)

View file

@ -1,14 +1,23 @@
# Add the root of the project to the $LOAD_PATH, For some reason it seems
# to be getting lost when we use warble to make the jar. This fixes it :D
$LOAD_PATH.unshift(ROOT)
$LOAD_PATH.unshift(ENV['KIBANA_ROOT'])
require "rack/reverse_proxy"
require "logger"
require "routes/home"
require "routes/proxy"
require "json"
require "lib/JSONLogger"
class Logger
alias_method :write, :<<
end
module Kibana
class App < Sinatra::Base
configure do
logger = Logger.new(STDOUT)
use JSONLogger, logger
end
# Routes go here
use Routes::Home
use Routes::Proxy