Class: Afterlife::Cdn::Server
- Inherits:
-
Object
- Object
- Afterlife::Cdn::Server
- Defined in:
- lib/afterlife/cdn/server.rb
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Server
constructor
A new instance of Server.
- #start ⇒ Object
Constructor Details
#initialize(args) ⇒ Server
Returns a new instance of Server.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/afterlife/cdn/server.rb', line 28 def initialize(args) @instance = Rackup::Server.new( environment: ENV['RACK_ENV'] || 'development', quiet: true, # we setup log in config.ru Port: args['port'], config: Afterlife.root.join('config.ru').to_s, pid: Server.pid_file.to_s, daemonize: !args['foreground'], ) end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
6 7 8 |
# File 'lib/afterlife/cdn/server.rb', line 6 def instance @instance end |
Class Method Details
.kill ⇒ Object
12 13 14 15 16 |
# File 'lib/afterlife/cdn/server.rb', line 12 def self.kill fail Afterlife::Error, 'The server is not running' unless running? Process.kill('INT', pid_file.read.to_i) end |
.pid_file ⇒ Object
8 9 10 |
# File 'lib/afterlife/cdn/server.rb', line 8 def self.pid_file Afterlife.local_path.join('pids/server.pid') end |
.running? ⇒ Boolean
24 25 26 |
# File 'lib/afterlife/cdn/server.rb', line 24 def self.running? pid_file.exist? end |
Instance Method Details
#start ⇒ Object
39 40 41 |
# File 'lib/afterlife/cdn/server.rb', line 39 def start instance.start end |