Skip to content

Commit

Permalink
Merge branch 'tkt_white_4312_review_web_ui' of https://git.assembla.c…
Browse files Browse the repository at this point in the history
…om/faraday into tkt_white_4312_review_web_ui
  • Loading branch information
f-amato committed Oct 13, 2017
2 parents ea13d6f + 239f614 commit 44988c0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions server/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# See the file 'doc/LICENSE' for the license information

import os
import sys
import functools
import twisted.web
from twisted.web.resource import Resource
Expand All @@ -18,15 +19,15 @@
from server.app import create_app

app = create_app() # creates a Flask(__name__) app

logger = server.utils.logger.get_logger(__name__)

class WebServer(object):
UI_URL_PATH = '_ui'
API_URL_PATH = '_api'
WEB_UI_LOCAL_PATH = os.path.join(server.config.FARADAY_BASE, 'server/www')

def __init__(self, enable_ssl=False):
logger.get_logger(__name__).info('Starting server at port {0} with bind address {1}. SSL {2}'.format(
logger.info('Starting server at port {0} with bind address {1}. SSL {2}'.format(
server.config.faraday_server.port,
server.config.faraday_server.bind_address,
enable_ssl))
Expand All @@ -43,7 +44,7 @@ def __config_server(self):
def __load_ssl_certs(self):
certs = (server.config.ssl.keyfile, server.config.ssl.certificate)
if not all(certs):
logger.get_logger(__name__).critical("HTTPS request but SSL certificates are not configured")
logger.critical("HTTPS request but SSL certificates are not configured")
exit(1) # Abort web-server startup
return ssl.DefaultOpenSSLContextFactory(*certs)

Expand Down Expand Up @@ -71,8 +72,11 @@ def run(self):
self.__couchdb_port = int(server.config.couchdb.port)
self.__listen_func = reactor.listenTCP

self.__listen_func(
self.__listen_port, site,
interface=self.__bind_address)
try:
self.__listen_func(
self.__listen_port, site,
interface=self.__bind_address)
except Exception as e:
logger.error('Something went wrong when trying to setup the Web UI')
reactor.run()

0 comments on commit 44988c0

Please sign in to comment.