diff --git a/src/allmydata/scripts/startstop_node.py b/src/allmydata/scripts/startstop_node.py index 5045bd6..9a5417e 100644 --- a/src/allmydata/scripts/startstop_node.py +++ b/src/allmydata/scripts/startstop_node.py @@ -149,7 +149,6 @@ def restart(config, stdout, stderr): def run(config, stdout, stderr): from twisted.internet import reactor from twisted.python import log, logfile - from allmydata import client basedir = config['basedir'] precondition(isinstance(basedir, unicode), basedir) @@ -164,14 +163,22 @@ def run(config, stdout, stderr): else: print >>stderr, "%s does not look like a node directory (no .tac file)" % quote_output(basedir) return 1 - if "client" not in tac: - print >>stderr, ("%s looks like it contains a non-client node (%s).\n" - "Use 'tahoe start' instead of 'tahoe run'." - % (quote_output(basedir), tac)) - return 1 os.chdir(basedir) + if tac == "tahoe-client.tac": + from allmydata import client + nodetype = client.Client + elif tac == "tahoe-introducer.tac": + from allmydata.introducer.server import IntroducerNode + nodetype = IntroducerNode + else: + print >>stderr, ("I don't know how to start the node in %s\n" + "(I only know how to start clients and introducers)\n" + "Please use 'tahoe start' instead of 'tahoe run'." + % (quote_output(basedir),)) + return 1 + # set up twisted logging. this will become part of the node rsn. logdir = os.path.join(basedir, 'logs') if not os.path.exists(logdir): @@ -180,7 +187,7 @@ def run(config, stdout, stderr): log.startLogging(lf) # run the node itself - c = client.Client(basedir) + c = nodetype(basedir) reactor.callLater(0, c.startService) # after reactor startup reactor.run() diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 4e9f683..82be33b 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -687,6 +687,19 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin, self.failUnlessEqual(rc_or_sig, 1) self.failUnless("does not look like a directory at all" in err, err) d.addCallback(_cb3) + + def _then_run_in_unknown_dir(res): + unknowndir = os.path.join(basedir, "unknown") + fileutil.make_dirs(unknowndir) + fileutil.write(os.path.join(unknowndir, "unknown.tac"), "") + return self.run_bintahoe(["--quiet", "run", "--basedir", unknowndir]) + d.addCallback(_then_run_in_unknown_dir) + def _cb4(res): + out, err, rc_or_sig = res + self.failUnlessEqual(rc_or_sig, 1) + self.failUnlessIn("I don't know how to start the node in", err) + d.addCallback(_cb4) + return d def test_keygen(self):