Class: Moneta::Server
Overview
Moneta server
Constant Summary
Constants included from Net
Instance Method Summary collapse
-
#initialize(store, options = {}) ⇒ Server
constructor
Constructor.
- #run ⇒ Object
- #running? ⇒ Boolean
- #stop ⇒ Object
Methods included from Net
Constructor Details
#initialize(store, options = {}) ⇒ Server
Constructor
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/moneta/server.rb', line 12 def initialize(store, = {}) @store = store @server = if @file = [:file] UNIXServer.open(@file) else TCPServer.open([:port] || DEFAULT_PORT) end @clients = [@server] @running = false end |
Instance Method Details
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/moneta/server.rb', line 28 def run raise 'Already running' if @running @stop = false @running = true begin until @stop mainloop end ensure File.unlink(@file) if @file end end |
#running? ⇒ Boolean
24 25 26 |
# File 'lib/moneta/server.rb', line 24 def running? @running end |
#stop ⇒ Object
41 42 43 44 45 46 |
# File 'lib/moneta/server.rb', line 41 def stop raise 'Not running' unless @running @stop = true @server.close @server = nil end |