phosphor-gevent: enable websocket support

Set 'WebSocketHandler' as the handler_class.

Websockets are being supported to allow the REST server to be able to
"push" events to clients.

Change-Id: I4c5536ae9070635c00330bb59fc93d3b4382b461
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/servers/gevent/phosphor-gevent b/servers/gevent/phosphor-gevent
index 9767407..7907880 100644
--- a/servers/gevent/phosphor-gevent
+++ b/servers/gevent/phosphor-gevent
@@ -21,6 +21,11 @@
 import os
 import gevent
 from gevent.pywsgi import WSGIServer
+have_wsock = True
+try:
+    from geventwebsocket.handler import WebSocketHandler
+except ImportError:
+    have_wsock = False
 
 if __name__ == '__main__':
     if len(sys.argv) < 2:
@@ -32,7 +37,10 @@
     default_cert = os.path.join(
         sys.prefix, 'share', os.path.basename(__file__), 'cert.pem')
 
-    app = App()
+    kw = {}
+    if have_wsock:
+        kw['have_wsock'] = True
+    app = App(**kw)
 
     if os.environ.get('LISTEN_PID', None) == str(os.getpid()):
         FIRST_SYSTEMD_SOCKET_FD = 3
@@ -42,6 +50,9 @@
     else:
         bind = ('', 443)
 
+    kw = {}
+    if have_wsock:
+        kw['handler_class'] = WebSocketHandler
     server = WSGIServer(
-        bind, app, keyfile=default_cert, certfile=default_cert)
+        bind, app, keyfile=default_cert, certfile=default_cert, **kw)
     server.serve_forever()