Class: Ella::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/ella/server.rb

Overview

This is not so much a server as a something which starts of the server and various listeners and initializers associated with Ella. From the point of view of the rest of Ella, this will be the server, though. This also restarts the server in development mode, something Sinatra is a bit shifty about on its own, due to Ruby restrictions.

Instance Method Summary collapse

Constructor Details

#initialize(mode: 'development', port: nil) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
17
18
19
# File 'lib/ella/server.rb', line 12

def initialize(mode: 'development', port: nil)
  Ella.find_root
  Log.yell("Starting server in #{mode} mode...")
  @mode = mode
  @port = port

  establish_pipelines
end

Instance Method Details

#css_pathObject



31
32
33
# File 'lib/ella/server.rb', line 31

def css_path
  @pipelines[:css].path
end

#js_pathObject



35
36
37
# File 'lib/ella/server.rb', line 35

def js_path
  @pipelines[:js].path
end

#runObject



21
22
23
24
25
26
27
28
29
# File 'lib/ella/server.rb', line 21

def run
  Ella.find_root
  @mode_path = File.join(Dir.pwd, 'temp/mode')
  File.open(@mode_path, 'w') { |f| f.puts(@mode) }
  RackfileGenerator.new.run

  Log.info('Staring Puma...')
  @mode == 'production' ? start_production_server : start_development_listener_loop
end