Class: ZygoteServer
- Inherits:
-
Object
- Object
- ZygoteServer
- Defined in:
- lib/zygote/server.rb
Instance Method Summary collapse
-
#initialize(port: 7000, threads: 1000, host: '0.0.0.0', config_path: nil, cells: [], debug: false) ⇒ ZygoteServer
constructor
A new instance of ZygoteServer.
- #run ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(port: 7000, threads: 1000, host: '0.0.0.0', config_path: nil, cells: [], debug: false) ⇒ ZygoteServer
Returns a new instance of ZygoteServer.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/zygote/server.rb', line 5 def initialize(port: 7000, threads:1000, host: '0.0.0.0', config_path: nil, cells: [], debug:false) debug ||= ENV['DEBUG'] cell_config = YAML.load(File.read(config_path || File.join(Dir.pwd, 'config', 'cells.yml'))) ZygoteWeb.views = [File.('../../../views', __FILE__), cells].flatten ZygoteWeb.cell_config = cell_config if debug $stdout.sync = true $stderr.sync = true end app = ZygoteWeb.new dispatch = Rack::Builder.app do map '/' do run app end end Thin::Logging.trace=true if debug @server = Thin::Server.new(port, host, dispatch, threadpool_size: threads).backend end |
Instance Method Details
#run ⇒ Object
33 34 35 36 37 38 |
# File 'lib/zygote/server.rb', line 33 def run EM.run do init_sighandlers @server.start end end |
#start ⇒ Object
26 27 28 29 30 31 |
# File 'lib/zygote/server.rb', line 26 def start @server.start rescue => ex puts ex puts ex.backtrace.join("\n") end |