-
Notifications
You must be signed in to change notification settings - Fork 11
Installation and Configuration
The application server uses a threaded connection pool so in order to take full advantage of threaded processing it is recommend that you use either JRuby or Rubinius when running Batsd-dash.
The easiest way to manage Ruby installations is to use RVM.
Once Ruby is installed and available you can now install the Batsd-dash gem. To install the gem run the following command:
gem install batsd-dash
You can also use Bundler to manage dependencies for your Bats-dash instance. Create a new Gemfile
file and add the following:
source :rubygems
gem 'batsd-dash'
Now run bundle install
to install Batsd-dash.
Now you need to create a rackup file for your Batsd-dash instance. Create a new config.ru
file and add the following:
require 'batsd-dash'
Batsd::Dash.config = {
host: 'localhost', port: 8127, size: 5, timeout: 5,
view_path: File.expand_path('..', __FILE__)
}
require 'batsd-dash/app'
run Batsd::Dash::App
Make sure you first require "batsd-dash"
, then configure it by setting Batsd::Dash.config
with some options hash. Settings this value is optional, the defaults are listed below.
After the configuration is set, it is now safe to require "batsd-dash/app"
and run it via Rack.
-
host: The hostname of the batsd data server. Defaults to
localhost
. -
port: The port number of the batsd data server. Defaults to
8127
. -
size: Connection pool size. Defauls to
5
-
timeout: Connection pool timeout. Defaults to
5
-
view_path: Path to use for custom pages. Defaults to
nil
. Totally optionally, see Custom Pages for more information.
Since the dash application is just another Rack app, you can use middlewares and other Rack apps with it.
For example, suppose you want to put basic HTTP auth around your application:
# batsd-dash app
require 'batsd-dash/app'
app = Batsd::Dash::App.new
# digest auth middleware
auth = Rack::Auth::Digest::MD5.new(app) do |username|
{ 'username' => 'password' }[username]
end
auth.realm = 'Digest Realm'
auth.opaque = 'secretkey'
# run the app
run auth