From: Brian Warner Date: Mon, 18 Feb 2008 07:28:17 +0000 (-0700) Subject: 'tahoe start': allow this to start arbitrary .tac file -bearing directories (like... X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/COPYING.TGPPL.html?a=commitdiff_plain;h=6ff98a3c0b54e6a3930a97a01707c085436fae37;p=tahoe-lafs%2Ftahoe-lafs.git 'tahoe start': allow this to start arbitrary .tac file -bearing directories (like the log gatherer) --- diff --git a/src/allmydata/scripts/startstop_node.py b/src/allmydata/scripts/startstop_node.py index aa7bc0c3..c79bad11 100644 --- a/src/allmydata/scripts/startstop_node.py +++ b/src/allmydata/scripts/startstop_node.py @@ -35,23 +35,22 @@ class RunOptions(usage.Options): def do_start(basedir, profile=False, out=sys.stdout, err=sys.stderr): print >>out, "STARTING", basedir - if os.path.exists(os.path.join(basedir, "client.tac")): - tac = "client.tac" - type = "client" - elif os.path.exists(os.path.join(basedir, "tahoe-client.tac")): - tac = "tahoe-client.tac" - type = "client" - elif os.path.exists(os.path.join(basedir, "introducer.tac")): - tac = "introducer.tac" - type = "introducer" - elif os.path.exists(os.path.join(basedir, "tahoe-introducer.tac")): - tac = "tahoe-introducer.tac" - type = "introducer" + if not os.path.isdir(basedir): + print >>err, "%s does not look like a directory at all" % basedir + return 1 + for fn in os.listdir(basedir): + if fn.endswith(".tac"): + tac = fn + break else: - print >>err, "%s does not look like a node directory" % basedir - if not os.path.isdir(basedir): - print >>err, " in fact, it doesn't look like a directory at all!" + print >>err, "%s does not look like a node directory (no .tac file)" % basedir return 1 + if "client" in tac: + nodetype = "client" + elif "introducer" in tac: + nodetype = "introducer" + else: + nodetype = "unknown (%s)" % tac cmd = find_exe.find_exe('twistd') if not cmd: @@ -59,7 +58,9 @@ def do_start(basedir, profile=False, out=sys.stdout, err=sys.stderr): sys.exit(1) fileutil.make_dirs(os.path.join(basedir, "logs")) - cmd.extend(["-y", tac, "--logfile", os.path.join("logs", "twistd.log")]) + cmd.extend(["-y", tac]) + if nodetype in ("client", "introducer"): + cmd.extend(["--logfile", os.path.join("logs", "twistd.log")]) if profile: cmd.extend(["--profile=profiling_results.prof", "--savestats",]) curdir = os.getcwd() @@ -69,10 +70,10 @@ def do_start(basedir, profile=False, out=sys.stdout, err=sys.stderr): finally: os.chdir(curdir) if rc == 0: - print >>out, "%s node probably started" % type + print >>out, "%s node probably started" % nodetype return 0 else: - print >>err, "%s node probably not started" % type + print >>err, "%s node probably not started" % nodetype return 1 def do_stop(basedir, out=sys.stdout, err=sys.stderr): diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index aa71c179..5bd90ddb 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -215,8 +215,7 @@ class RunNode(unittest.TestCase, testutil.PollMixin): out,err = StringIO(), StringIO() rc = runner.runner(argv, stdout=out, stderr=err) self.failUnlessEqual(rc, 1) - self.failUnless("does not look like a node directory" in err.getvalue()) - self.failUnless("doesn't look like a directory at all" - in err.getvalue()) + self.failUnless("does not look like a directory at all" + in err.getvalue(), err.getvalue())