+ return None
+
+ for t in ("client", "introducer", "key-generator", "stats-gatherer"):
+ if t in tac:
+ return t
+ return None
+
+def start(config, out=sys.stdout, err=sys.stderr):
+ basedir = config['basedir']
+ print >>out, "STARTING", quote_output(basedir)
+ if not os.path.isdir(basedir):
+ print >>err, "%s does not look like a directory at all" % quote_output(basedir)
+ return 1
+ nodetype = identify_node_type(basedir)
+ if not nodetype:
+ print >>err, "%s is not a recognizable node directory" % quote_output(basedir)
+ return 1
+ # Now prepare to turn into a twistd process. This os.chdir is the point
+ # of no return.
+ os.chdir(basedir)
+ twistd_args = []
+ if (nodetype in ("client", "introducer")
+ and "--nodaemon" not in config.twistd_args
+ and "--syslog" not in config.twistd_args
+ and "--logfile" not in config.twistd_args):
+ fileutil.make_dirs(os.path.join(basedir, "logs"))
+ twistd_args.extend(["--logfile", os.path.join("logs", "twistd.log")])
+ twistd_args.extend(config.twistd_args)
+ twistd_args.append("XYZ") # point at our NodeStartingPlugin
+
+ twistd_config = MyTwistdConfig()
+ try:
+ twistd_config.parseOptions(twistd_args)
+ except usage.error, ue:
+ # these arguments were unsuitable for 'twistd'
+ print >>err, twistd_config
+ print >>err, "tahoe start: %s" % (config.subCommand, ue)