Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Configuration filepath is now passed as a CLI param, set on Cucub::Se…

…rver@server_opts
  • Loading branch information...
commit 4d7b4b373de1b01d539df57d5226b8d2cc21daf5 1 parent f9a5865
@krakatoa krakatoa authored
View
32 lib/configuration.rb
@@ -1,32 +0,0 @@
-require 'singleton'
-
-module Cucub
- class Configuration
- include Singleton
-
- def initialize
- @loader = Cucub::Protocol::Loader.instance
- set_config_file
- reload
- end
-
- def set_config_file
- @loader.set_path("./config/protocol.ini")
- end
-
- def reload
- @specification_set = @loader.parse
- @uses = nil
- end
-
- def uses
- # lazy load array of uses
- return @uses if @uses
- uses = []
- uses << "box" if @specification_set.uses_box
- uses << "mailbox" if @specification_set.uses_mailbox
- uses << "board" if @specification_set.uses_board
- @uses = uses
- end
- end
-end
View
1  lib/cucub-server.rb
@@ -1,6 +1,5 @@
require 'cucub-protocol'
-require './lib/configuration'
require './lib/channel'
require './lib/dispatcher'
require './lib/server'
View
2  lib/dispatcher.rb
@@ -33,7 +33,7 @@ def start(block=nil)
end
@ipc_get = Cucub::Channel.ipc_get
=end
- if Cucub::Configuration.instance.uses.include? ("box")
+ if Cucub::Server::Configuration.instance.uses.include? ("box")
@box = Cucub::Channel.reply
end
View
60 lib/object.rb
@@ -1,60 +0,0 @@
-#require 'em-jack'
-#require 'json'
-
-require 'channel'
-require 'dispatcher'
-#require 'queue'
-#require 'live_object'
-#require 'live_proxy'
-
-#require 'worker'
-#require 'proxy_queue'
-#require 'proxy_worker'
-
-module Cucub
- @@dispatcher = Cucub::Dispatcher.instance
-#####
-=begin
- @@in_worker = false
-=end
-
- def self.start!(address, block=Proc.new({}))
- @@address = address
- #### Cucub::Channel.initialize
-
- # refactor !
- # separar este codigo en init y start (?)
- # mover codigo a cucub-server (?)
-#####
-=begin
- workers_pool = Servolux::Prefork.new(:module => Cucub::Worker)
- workers_pool.start 1
- trap("INT") {
- workers_pool.signal "INT"
- workers_pool.reap
- Cucub.shutdown!
- exit
- }
-=end
- @@dispatcher.start(block)
- end
-
- def self.shutdown!
- @@dispatcher.stop
- end
-
- def self.address
- @@address
- end
-
-#####
-=begin
- def self.in_worker
- @@in_worker = true
- end
-
- def self.in_worker?
- @@in_worker
- end
-=end
-end
View
6 lib/server.rb
@@ -1,4 +1,5 @@
require 'singleton'
+require './lib/server/configuration'
module Cucub
class Server
@@ -10,6 +11,7 @@ def initialize
def start!(server_opts={})
@address = server_opts[:host]
+ @config_filepath = server_opts[:config]
@dispatcher.start
end
@@ -20,6 +22,10 @@ def shutdown!
def address
@address
end
+
+ def config_filepath
+ @config_filepath
+ end
end
#def self.initialize(&block)
View
3  lib/server/cli.rb
@@ -13,6 +13,7 @@ class CLI < Thor
desc "start", "start cucub as a service"
method_option :host, :aliases => '-h', :default => '127.0.0.1', :type => :string
+ method_option :config, :aliases => '-c', :default => 'config/protocol.ini', :type => :string
def start(boot_file)
opts = options.dup
@@ -25,7 +26,7 @@ def start(boot_file)
logger.level = Logger::DEBUG
# encapsular esto en una clase de Cucub::Server
- pid_file = File.expand_path('cucub.pid')
+ pid_file = File.expand_path('cucub-server.pid')
# before server
#driver = Driver.instance
View
34 lib/server/configuration.rb
@@ -0,0 +1,34 @@
+require 'singleton'
+
+module Cucub
+ class Server
+ class Configuration
+ include Singleton
+
+ def initialize
+ @loader = Cucub::Protocol::Loader.instance
+ set_config_file
+ reload
+ end
+
+ def set_config_file
+ @loader.set_path(Cucub::Server.instance.config_filepath)
+ end
+
+ def reload
+ @specification_set = @loader.parse
+ @uses = nil
+ end
+
+ def uses
+ # lazy load array of uses
+ return @uses if @uses
+ uses = []
+ uses << "box" if @specification_set.uses_box
+ uses << "mailbox" if @specification_set.uses_mailbox
+ uses << "board" if @specification_set.uses_board
+ @uses = uses
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.