aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrwa/support/sessionservice/service.py20
-rw-r--r--rwa/support/sessionservice/session.py10
2 files changed, 20 insertions, 10 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py
index 2bc727d..e3ca5a1 100755
--- a/rwa/support/sessionservice/service.py
+++ b/rwa/support/sessionservice/service.py
@@ -191,7 +191,7 @@ class RWASupportSessionService(dbus.service.Object):
return json.dumps(return_json)
except ConnectionError:
- pass
+ logging.error("There was a connection error while trying to reach the server.")
return json.dumps({"status": "error", "type": "connection"})
@@ -321,11 +321,16 @@ class RWASupportSessionService(dbus.service.Object):
return False
def _stop_all(self):
- """Stop all sessions and this daemon."""
- logging.info("Stop all sessions and exit service.")
+ """Stop all sessions"""
+ logging.info("Stop all sessions.")
for session in list(self.sessions.values()):
session.stop()
del self.sessions[session.pid]
+
+ def _stop_daemon(self):
+ """Stop all sessions and this daemon."""
+ logging.info("Shut down session service.")
+ self._stop_all()
self.trigger_service.shutdown()
self.loop.quit()
@@ -387,11 +392,16 @@ def main(mockup, once):
loop = GLib.MainLoop()
service_object = RWASupportSessionService(loop, mockup, once)
- def signal_handler(sig, frame):
+ def sigint_handler(sig, frame):
logging.info("Service was terminated.")
+ service_object._stop_daemon()
+
+ def sigquit_handler(sig, frame):
+ logging.info("Session was terminated.")
service_object._stop_all()
- signal.signal(signal.SIGINT, signal_handler)
+ signal.signal(signal.SIGINT, sigint_handler)
+ signal.signal(signal.SIGQUIT, sigquit_handler)
loop.run()
diff --git a/rwa/support/sessionservice/session.py b/rwa/support/sessionservice/session.py
index 11c418e..0126800 100644
--- a/rwa/support/sessionservice/session.py
+++ b/rwa/support/sessionservice/session.py
@@ -146,21 +146,21 @@ class Session:
self.stop(triggered=True)
raise ConnectionError()
+ if r.status_code != 200:
+ self.stop(triggered=True)
+ raise ConnectionError()
+
logging.info(
"The session has been registered in RWA.Support.WebApp "
f"with status code {r.status_code} and response {r.content.decode()}."
)
- if r.status_code != 200:
- self.stop(triggered=True)
- raise ConnectionError()
-
self.meta = r.json()
self.session_id = self.meta["session_id"]
self.web_url = self.meta["url"]
self.api_token = self.meta["token"]
else:
- logging.info("The session has pretended that he had created a session.")
+ logging.info("The service has pretended that he had created a session.")
self.meta = {}
self.session_id = int(random_digits(10))
self.web_url = f"http://example.com:{random_digits(5)}/app/rwasupport/test/"