summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/app.py
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2014-07-24 12:54:12 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2014-12-19 17:15:55 -0300
commitdf160c0d44e8d0439d54313f097b2a4d9ada7357 (patch)
treec3d2cb9f68f696bc9377dbaf20897cf0a560afde /src/leap/bitmask/app.py
parent30b02e9153b21d177bf0f79e7132157bf25b636d (diff)
Allow frontend and backend to be run separately.
Add the 'check_online' method to check whether the backend is accessible or not. Reduce the wait for running threads timeout on quit. Add retry feature to the backend requests send.
Diffstat (limited to 'src/leap/bitmask/app.py')
-rw-r--r--src/leap/bitmask/app.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/leap/bitmask/app.py b/src/leap/bitmask/app.py
index 87f22d88..ef156671 100644
--- a/src/leap/bitmask/app.py
+++ b/src/leap/bitmask/app.py
@@ -44,6 +44,7 @@ import os
import sys
+from leap.bitmask.backend.backend_proxy import BackendProxy
from leap.bitmask.backend.utils import generate_certificates
from leap.bitmask import __version__ as VERSION
@@ -178,19 +179,29 @@ def start_app():
logger.info('Starting app')
- generate_certificates()
+ backend = BackendProxy()
+ backend_running = backend.check_online()
- flags_dict = flags_to_dict()
+ logger.debug("Backend online: {0}".format(backend_running))
+
+ if not backend_running:
+ generate_certificates()
- frontend_pid = os.getpid()
- backend = lambda: run_backend(opts.danger, flags_dict, frontend_pid)
- backend_process = multiprocessing.Process(target=backend, name='Backend')
- # we don't set the 'daemon mode' since we need to start child processes in
- # the backend
- # backend_process.daemon = True
- backend_process.start()
+ flags_dict = flags_to_dict()
- run_frontend(options, flags_dict, backend_pid=backend_process.pid)
+ backend_pid = None
+ if not backend_running:
+ frontend_pid = os.getpid()
+ backend = lambda: run_backend(opts.danger, flags_dict, frontend_pid)
+ backend_process = multiprocessing.Process(target=backend,
+ name='Backend')
+ # we don't set the 'daemon mode' since we need to start child processes
+ # in the backend
+ # backend_process.daemon = True
+ backend_process.start()
+ backend_pid = backend_process.pid
+
+ run_frontend(options, flags_dict, backend_pid=backend_pid)
if __name__ == "__main__":