Permalink
Browse files

Added standalone bin/websocket-server.rb , for use when the XMPP/fore…

…st features will not be used.
  • Loading branch information...
Pistos committed Feb 19, 2015
1 parent efda36a commit 52598f485f2f829e391e9df0b57f76255114a7e4
Showing with 34 additions and 0 deletions.
  1. +34 −0 bin/websocket-server.rb
View
@@ -0,0 +1,34 @@
require 'libertree/db'
if ARGV[0].nil?
$stderr.puts "#{$0} <config.yaml> <database.yaml>"
exit 1
end
if ARGV[1].nil?
$stderr.puts "no database configuration file given; assuming #{File.dirname( __FILE__ ) }/../database.yaml"
db_config = "#{File.dirname( __FILE__ ) }/../database.yaml"
else
db_config = ARGV[1]
end
########################
# Sequel wants us to connect to the db before defining models. As model
# definitions are loaded when 'libertree/server' is required, we have to do
# this first.
Libertree::DB.load_config db_config
Libertree::DB.dbh
########################
require 'libertree/model'
require 'libertree/server/websocket'
Thread.abort_on_exception = true
conf = YAML.load(
File.read("#{File.dirname( __FILE__ ) }/../defaults.yaml")
).merge YAML.load(File.read(ARGV[0]))
EventMachine.run do
Libertree::Server::Websocket.run(conf)
end

0 comments on commit 52598f4

Please sign in to comment.