-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
executable file
·27 lines (24 loc) · 826 Bytes
/
server.py
File metadata and controls
executable file
·27 lines (24 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from SocketServer import ThreadingTCPServer
from handler import CacheRequestHandler
from logger import Logger
class CacheServer():
"""
This class has the responsibility to listen and answer requests done by
different clients
"""
def configure(self, cfg):
Logger().info("Configuring Server")
self.host = cfg.host
self.port = cfg.port
Logger().info("Server configured")
def start(self):
"""Start cache and administration services"""
server_address = (self.host, self.port)
Logger().info("Starting server on %s:%s" % server_address)
self.server_instance = ThreadingTCPServer(server_address, CacheRequestHandler)
self.server_instance.serve_forever()
def stop(self):
"""Stop running services"""
if self.server_instance:
self.server_instance.server_close()
Logger().info("Stopping server")