diff --git a/src/allmydata/scripts/startstop_node.py b/src/allmydata/scripts/startstop_node.py
index 5045bd6..9a5417e 100644
a
|
b
|
def restart(config, stdout, stderr): |
149 | 149 | def run(config, stdout, stderr): |
150 | 150 | from twisted.internet import reactor |
151 | 151 | from twisted.python import log, logfile |
152 | | from allmydata import client |
153 | 152 | |
154 | 153 | basedir = config['basedir'] |
155 | 154 | precondition(isinstance(basedir, unicode), basedir) |
… |
… |
def run(config, stdout, stderr): |
164 | 163 | else: |
165 | 164 | print >>stderr, "%s does not look like a node directory (no .tac file)" % quote_output(basedir) |
166 | 165 | return 1 |
167 | | if "client" not in tac: |
168 | | print >>stderr, ("%s looks like it contains a non-client node (%s).\n" |
169 | | "Use 'tahoe start' instead of 'tahoe run'." |
170 | | % (quote_output(basedir), tac)) |
171 | | return 1 |
172 | 166 | |
173 | 167 | os.chdir(basedir) |
174 | 168 | |
| 169 | if tac == "tahoe-client.tac": |
| 170 | from allmydata import client |
| 171 | nodetype = client.Client |
| 172 | elif tac == "tahoe-introducer.tac": |
| 173 | from allmydata.introducer.server import IntroducerNode |
| 174 | nodetype = IntroducerNode |
| 175 | else: |
| 176 | print >>stderr, ("I don't know how to start the node in %s\n" |
| 177 | "(I only know how to start clients and introducers)\n" |
| 178 | "Please use 'tahoe start' instead of 'tahoe run'." |
| 179 | % (quote_output(basedir),)) |
| 180 | return 1 |
| 181 | |
175 | 182 | # set up twisted logging. this will become part of the node rsn. |
176 | 183 | logdir = os.path.join(basedir, 'logs') |
177 | 184 | if not os.path.exists(logdir): |
… |
… |
def run(config, stdout, stderr): |
180 | 187 | log.startLogging(lf) |
181 | 188 | |
182 | 189 | # run the node itself |
183 | | c = client.Client(basedir) |
| 190 | c = nodetype(basedir) |
184 | 191 | reactor.callLater(0, c.startService) # after reactor startup |
185 | 192 | reactor.run() |
186 | 193 | |
diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py
index 4e9f683..82be33b 100644
a
|
b
|
class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin, |
687 | 687 | self.failUnlessEqual(rc_or_sig, 1) |
688 | 688 | self.failUnless("does not look like a directory at all" in err, err) |
689 | 689 | d.addCallback(_cb3) |
| 690 | |
| 691 | def _then_run_in_unknown_dir(res): |
| 692 | unknowndir = os.path.join(basedir, "unknown") |
| 693 | fileutil.make_dirs(unknowndir) |
| 694 | fileutil.write(os.path.join(unknowndir, "unknown.tac"), "") |
| 695 | return self.run_bintahoe(["--quiet", "run", "--basedir", unknowndir]) |
| 696 | d.addCallback(_then_run_in_unknown_dir) |
| 697 | def _cb4(res): |
| 698 | out, err, rc_or_sig = res |
| 699 | self.failUnlessEqual(rc_or_sig, 1) |
| 700 | self.failUnlessIn("I don't know how to start the node in", err) |
| 701 | d.addCallback(_cb4) |
| 702 | |
690 | 703 | return d |
691 | 704 | |
692 | 705 | def test_keygen(self): |