mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-18 23:38:18 +00:00
Better name for the file that causes a node to exit after a timeout when running unit tests. refs #1336
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
@ -109,7 +109,7 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
PORTNUMFILE = "client.port"
|
||||
STOREDIR = 'storage'
|
||||
NODETYPE = "client"
|
||||
SUICIDE_PREVENTION_HOTLINE_FILE = "suicide_prevention_hotline"
|
||||
EXIT_TRIGGER_FILE = "exit_trigger"
|
||||
|
||||
# This means that if a storage server treats me as though I were a
|
||||
# 1.0.0 storage client, it will work as they expect.
|
||||
@ -150,13 +150,16 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
self.init_sftp_server()
|
||||
self.init_drop_uploader()
|
||||
|
||||
hotline_file = os.path.join(self.basedir,
|
||||
self.SUICIDE_PREVENTION_HOTLINE_FILE)
|
||||
if os.path.exists(hotline_file):
|
||||
age = time.time() - os.stat(hotline_file)[stat.ST_MTIME]
|
||||
self.log("hotline file noticed (%ds old), starting timer" % age)
|
||||
hotline = TimerService(1.0, self._check_hotline, hotline_file)
|
||||
hotline.setServiceParent(self)
|
||||
# If the node sees an exit_trigger file, it will poll every second to see
|
||||
# whether the file still exists, and what its mtime is. If the file does not
|
||||
# exist or has not been modified for a given timeout, the node will exit.
|
||||
exit_trigger_file = os.path.join(self.basedir,
|
||||
self.EXIT_TRIGGER_FILE)
|
||||
if os.path.exists(exit_trigger_file):
|
||||
age = time.time() - os.stat(exit_trigger_file)[stat.ST_MTIME]
|
||||
self.log("%s file noticed (%ds old), starting timer" % (self.EXIT_TRIGGER_FILE, age))
|
||||
exit_trigger = TimerService(1.0, self._check_exit_trigger, exit_trigger_file)
|
||||
exit_trigger.setServiceParent(self)
|
||||
|
||||
# this needs to happen last, so it can use getServiceNamed() to
|
||||
# acquire references to StorageServer and other web-statusable things
|
||||
@ -492,15 +495,15 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
except Exception, e:
|
||||
self.log("couldn't start drop-uploader: %r", args=(e,))
|
||||
|
||||
def _check_hotline(self, hotline_file):
|
||||
if os.path.exists(hotline_file):
|
||||
mtime = os.stat(hotline_file)[stat.ST_MTIME]
|
||||
def _check_exit_trigger(self, exit_trigger_file):
|
||||
if os.path.exists(exit_trigger_file):
|
||||
mtime = os.stat(exit_trigger_file)[stat.ST_MTIME]
|
||||
if mtime > time.time() - 120.0:
|
||||
return
|
||||
else:
|
||||
self.log("hotline file too old, shutting down")
|
||||
self.log("%s file too old, shutting down" % (self.EXIT_TRIGGER_FILE,))
|
||||
else:
|
||||
self.log("hotline file missing, shutting down")
|
||||
self.log("%s file missing, shutting down" % (self.EXIT_TRIGGER_FILE,))
|
||||
reactor.stop()
|
||||
|
||||
def get_encoding_parameters(self):
|
||||
|
Reference in New Issue
Block a user