optParameters = [
["basedir", "C", None, "which directory to start the node in"],
]
+ optFlags = [
+ ["profile", "p", "whether to run under the Python profiler, putting results in \"profiling_results.prof\""],
+ ]
class StopOptions(BasedirMixin, usage.Options):
optParameters = [
"of 'restart'"],
]
-def do_start(basedir, out=sys.stdout, err=sys.stderr):
+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"
fileutil.make_dirs(os.path.join(basedir, "logs"))
cmd.extend(["-y", tac, "--logfile", os.path.join("logs", "twistd.log")])
+ if profile:
+ cmd.extend(["--profile=profiling_results.prof", "--savestats",])
curdir = os.getcwd()
try:
os.chdir(basedir)
def start(config, stdout, stderr):
rc = 0
for basedir in config['basedirs']:
- rc = do_start(basedir, stdout, stderr) or rc
+ rc = do_start(basedir, config['profile'], stdout, stderr) or rc
return rc
def stop(config, stdout, stderr):