aboutsummaryrefslogtreecommitdiff
path: root/rwa/support
diff options
context:
space:
mode:
authorJonathan Weth <git@jonathanweth.de>2021-06-28 12:57:23 +0200
committerJonathan Weth <git@jonathanweth.de>2021-06-28 12:57:23 +0200
commit9c437fabc0bd3d924413f5e3c0b08f365ca64f9d (patch)
treea5a1fadc5201718b3f204ca7b91db1d7b09aa407 /rwa/support
parente67b9b7ef03ad48aad62dd82b48fb7fdfe3949a8 (diff)
parentd8146354959fb352f9709ae0d2a674c361dbec17 (diff)
downloadRWA.Support.SessionService-9c437fabc0bd3d924413f5e3c0b08f365ca64f9d.tar.gz
RWA.Support.SessionService-9c437fabc0bd3d924413f5e3c0b08f365ca64f9d.tar.bz2
RWA.Support.SessionService-9c437fabc0bd3d924413f5e3c0b08f365ca64f9d.zip
Merge branch 'master' into feature/multiple-hosts
Diffstat (limited to 'rwa/support')
-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/"