[X2Go-Commits] [python-x2go] 04/07: Better control the startup bootstrap of the Telekinesis client subsystem.
git-admin at x2go.org
git-admin at x2go.org
Wed Jun 25 01:30:11 CEST 2014
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository python-x2go.
commit 894917eee64a58a7a5d337991c8623d6b097e919
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Tue Jun 24 16:22:06 2014 +0200
Better control the startup bootstrap of the Telekinesis client subsystem.
---
debian/changelog | 2 ++
x2go/telekinesis.py | 89 +++++++++++++++++++++++++++++----------------------
2 files changed, 52 insertions(+), 39 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 2cf3eaf..8e0a24c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -72,6 +72,8 @@ python-x2go (0.5.0.0-0x2go1) UNRELEASED; urgency=low
debug mode.
- Performance tests have shown, that enabling SSH compression is not a
good idea. NX should handle that instead (and does).
+ - Better control the startup bootstrap of the Telekinesis client
+ subsystem.
* debian/control:
+ Add dependencies: python-requests, python-simplejson.
* python-x2go.spec:
diff --git a/x2go/telekinesis.py b/x2go/telekinesis.py
index b32b30f..f14c4e7 100644
--- a/x2go/telekinesis.py
+++ b/x2go/telekinesis.py
@@ -165,6 +165,11 @@ class X2GoTelekinesisClient(threading.Thread):
self.logger('Telekinesis client shutdown gave a message that we may ignore: %s' % str(e), loglevel=log.loglevel_WARN)
self.tekiclient = None
+ if self.fw_ctrl_tunnel is not None:
+ self.logger('Shutting down Telekinesis wormhole', loglevel=log.loglevel_DEBUG)
+ forward.stop_forward_tunnel(self.fw_ctrl_tunnel)
+ self.fw_ctrl_tunnel = None
+
if self.telekinesis_sshfs is not None:
telekinesis_sshfs_command = ['fusermount', '-u', '/tmp/.x2go-{local_user}/telekinesis/S-{sid}/'.format(local_user=_CURRENT_LOCAL_USER, sid=self.session_info), ]
self.logger('Umounting SSHFS mount for Telekinesis via forking a threaded subprocess: %s' % " ".join(telekinesis_sshfs_command), loglevel=log.loglevel_DEBUG)
@@ -176,10 +181,6 @@ class X2GoTelekinesisClient(threading.Thread):
shell=False)
self.telekinesis_sshfs = None
- if self.fw_ctrl_tunnel is not None:
- self.logger('Shutting down Telekinesis wormhole', loglevel=log.loglevel_DEBUG)
- forward.stop_forward_tunnel(self.fw_ctrl_tunnel)
- self.fw_ctrl_tunnel = None
if self.fw_data_tunnel is not None:
self.logger('Shutting down Telekinesis DATA tunnel', loglevel=log.loglevel_DEBUG)
forward.stop_forward_tunnel(self.fw_data_tunnel)
@@ -248,29 +249,30 @@ class X2GoTelekinesisClient(threading.Thread):
cmd_line = self._generate_cmdline()
- self.tekiclient_log_stdout = open('%s/%s' % (self.session_info.local_container, self.tekiclient_log, ), 'a')
- self.tekiclient_log_stderr = open('%s/%s' % (self.session_info.local_container, self.tekiclient_log, ), 'a')
- self.logger('forking threaded subprocess: %s' % " ".join(cmd_line), loglevel=log.loglevel_DEBUG)
+ if self.session_info and self.session_info.local_container:
+ self.tekiclient_log_stdout = open('%s/%s' % (self.session_info.local_container, self.tekiclient_log, ), 'a')
+ self.tekiclient_log_stderr = open('%s/%s' % (self.session_info.local_container, self.tekiclient_log, ), 'a')
+ self.logger('forking threaded subprocess: %s' % " ".join(cmd_line), loglevel=log.loglevel_DEBUG)
- while not self.tekiclient:
- gevent.sleep(.2)
- p = self.tekiclient = subprocess.Popen(cmd_line,
- env=self.TEKICLIENT_ENV,
- stdin=None,
- stdout=self.tekiclient_log_stdout,
- stderr=self.tekiclient_log_stderr,
- shell=False)
+ while not self.tekiclient:
+ gevent.sleep(.2)
+ p = self.tekiclient = subprocess.Popen(cmd_line,
+ env=self.TEKICLIENT_ENV,
+ stdin=None,
+ stdout=self.tekiclient_log_stdout,
+ stderr=self.tekiclient_log_stderr,
+ shell=False)
- while self._keepalive:
- gevent.sleep(.05)
+ while self._keepalive:
+ gevent.sleep(1)
- try:
- p.terminate()
- self.logger('terminating Telekinesis client: %s' % p, loglevel=log.loglevel_DEBUG)
- except OSError, e:
- if e.errno == 3:
- # No such process
- pass
+ try:
+ p.terminate()
+ self.logger('terminating Telekinesis client: %s' % p, loglevel=log.loglevel_DEBUG)
+ except OSError, e:
+ if e.errno == 3:
+ # No such process
+ pass
self.tekiclient = None
@@ -347,23 +349,32 @@ class X2GoTelekinesisClient(threading.Thread):
self.logger('waiting for Telekinesis data tunnel to come up: 0.5s x %s' % _count, loglevel=log.loglevel_DEBUG)
gevent.sleep(.5)
- gevent.sleep(1)
- threading.Thread.start(self)
+ # only start TeKi client if the data connection is up and running...
+ if self.fw_data_tunnel.is_active and self.telekinesis_sshfs:
- self.logger('Telekinesis client tries to connect to host=127.0.0.1, port=%s.' % (self.session_info.tekictrl_port,), loglevel=log.loglevel_DEBUG)
- self.logger('Telekinesis client writes its log to %s.' % os.path.join(self.session_info.local_container, self.tekiclient_log), loglevel=log.loglevel_DEBUG)
- while self.tekiclient is None and _count < _maxwait:
- _count += 1
- self.logger('waiting for Telekinesis client to come up: 0.4s x %s' % _count, loglevel=log.loglevel_DEBUG)
- gevent.sleep(.4)
+ gevent.sleep(1)
+ threading.Thread.start(self)
- # also wait for telekinesis wormhole to become active
- _count = 0
- _maxwait = 40
- while self.fw_ctrl_tunnel and (not self.fw_ctrl_tunnel.is_active) and (not self.fw_ctrl_tunnel.failed) and (_count < _maxwait):
- _count += 1
- self.logger('waiting for Telekinesis wormhole to come up: 0.5s x %s' % _count, loglevel=log.loglevel_DEBUG)
- gevent.sleep(.5)
+ self.logger('Telekinesis client tries to connect to host=127.0.0.1, port=%s.' % (self.session_info.tekictrl_port,), loglevel=log.loglevel_DEBUG)
+ self.logger('Telekinesis client writes its log to %s.' % os.path.join(self.session_info.local_container, self.tekiclient_log), loglevel=log.loglevel_DEBUG)
+ while self.tekiclient is None and _count < _maxwait:
+ _count += 1
+ self.logger('waiting for Telekinesis client to come up: 0.4s x %s' % _count, loglevel=log.loglevel_DEBUG)
+ gevent.sleep(.4)
+
+ # only wait for the TeKi wormhole tunnel (ctrl tunnel) if TeKi could be started successfully...
+ if self.tekiclient is not None:
+
+ # also wait for telekinesis wormhole to become active
+ _count = 0
+ _maxwait = 40
+ while self.fw_ctrl_tunnel and (not self.fw_ctrl_tunnel.is_active) and (not self.fw_ctrl_tunnel.failed) and (_count < _maxwait):
+ _count += 1
+ self.logger('waiting for Telekinesis wormhole to come up: 0.5s x %s' % _count, loglevel=log.loglevel_DEBUG)
+ gevent.sleep(.5)
+
+ else:
+ self.logger('Aborting Telekinesis client startup for session %s, because the Telekinesis data connection failed to be established.' % (self.session_info,), loglevel=log.loglevel_WARN)
return self.tekiclient, bool(self.tekiclient) and (self.fw_ctrl_tunnel and self.fw_ctrl_tunnel.is_active)
--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/python-x2go.git
More information about the x2go-commits
mailing list