Ticket #1190: 1190-nospawn.darcs.patch

File 1190-nospawn.darcs.patch, 7.8 KB (added by warner, at 2010-10-27T06:42:17Z)

import+exec twistd, instead of find+spawn, to remove an intermediate process

Line 
1Tue Oct 26 23:13:42 PDT 2010  "Brian Warner <warner@lothar.com>"
2  * 'tahoe start': use import+call rather than find+spawn
3 
4  This removes the need to use a locally-built (dependency) bin/twistd, and
5  removes a big chunk of behavior differences between unix and windows. It
6  also happens to resolve the "client node probably started" uncertainty.
7  Might help with #1190, #602, and #71.
8
9New patches:
10
11['tahoe start': use import+call rather than find+spawn
12"Brian Warner <warner@lothar.com>"**20101027061342
13 
14 This removes the need to use a locally-built (dependency) bin/twistd, and
15 removes a big chunk of behavior differences between unix and windows. It
16 also happens to resolve the "client node probably started" uncertainty.
17 Might help with #1190, #602, and #71.
18] {
19hunk ./src/allmydata/scripts/startstop_node.py 51
20     else:
21         nodetype = "unknown (%s)" % tac
22 
23-    cmd = find_exe.find_exe('twistd')
24-    if not cmd:
25-        # If 'twistd' wasn't on $PATH, maybe we're running from source and
26-        # Twisted was built as one of our dependencies. If so, we're at
27-        # BASEDIR/src/allmydata/scripts/startstop_node.py, and it's at
28-        # BASEDIR/support/$BINDIR/twistd
29-        up = os.path.dirname
30-        TAHOEDIR = up(up(up(up(os.path.abspath(__file__)))))
31-        if sys.platform == "win32":
32-            bin_dir = "Scripts"
33-        else:
34-            bin_dir = "bin"
35-        bindir = os.path.join(TAHOEDIR, "support", bin_dir)
36-
37-        maybe = os.path.join(bindir, "twistd")
38-        if os.path.exists(maybe):
39-            cmd = [maybe]
40-            oldpath = os.environ.get("PATH", "").split(os.pathsep)
41-            os.environ["PATH"] = os.pathsep.join(oldpath + [bindir])
42-            # sys.path and $PYTHONPATH are taken care of by the extra code in
43-            # 'setup.py trial'
44-        else:
45-            maybe = maybe+'.py'
46-            if os.path.exists(maybe):
47-                cmd = [sys.executable, maybe]
48-                oldpath = os.environ.get("PATH", "").split(os.pathsep)
49-                os.environ["PATH"] = os.pathsep.join(oldpath + [bindir])
50-                # sys.path and $PYTHONPATH are taken care of by the extra code in
51-                # 'setup.py trial'
52-
53-    if not cmd:
54-        print "Can't find twistd (it comes with Twisted).  Aborting."
55-        sys.exit(1)
56-
57-    cmd.extend(["-y", tac])
58+    args = ["twistd", "-y", tac]
59     if opts["syslog"]:
60hunk ./src/allmydata/scripts/startstop_node.py 53
61-        cmd.append("--syslog")
62+        args.append("--syslog")
63     elif nodetype in ("client", "introducer"):
64         fileutil.make_dirs(os.path.join(basedir, "logs"))
65hunk ./src/allmydata/scripts/startstop_node.py 56
66-        cmd.extend(["--logfile", os.path.join("logs", "twistd.log")])
67+        args.extend(["--logfile", os.path.join("logs", "twistd.log")])
68     if opts["profile"]:
69hunk ./src/allmydata/scripts/startstop_node.py 58
70-        cmd.extend(["--profile=profiling_results.prof", "--savestats",])
71-    curdir = os.getcwd()
72-    try:
73-        os.chdir(basedir)
74-        rc = os.system(' '.join(cmd))
75-    finally:
76-        os.chdir(curdir)
77-    if rc == 0:
78-        print >>out, "%s node probably started" % nodetype
79-        return 0
80-    else:
81-        print >>err, "%s node probably not started" % nodetype
82-        return 1
83+        args.extend(["--profile=profiling_results.prof", "--savestats",])
84+    # now we're committed
85+    os.chdir(basedir)
86+    from twisted.scripts import twistd
87+    sys.argv = args
88+    twistd.run()
89+    # run() doesn't return: the parent does os._exit(0) in daemonize(), so
90+    # we'll never get here. If application setup fails (e.g. ImportError),
91+    # run() will raise an exception.
92 
93 def do_stop(basedir, out=sys.stdout, err=sys.stderr):
94     print >>out, "STOPPING", quote_output(basedir)
95}
96
97Context:
98
99[docs/known_issues.rst: Add section on traffic analysis. Fix URL for current version of file.
100david-sarah@jacaranda.org**20101024234259
101 Ignore-this: f3416e79d3bb833f5118da23e85723ad
102]
103[test_mutable.py: add test for ResponseCache memory leak. refs #1045, #1129
104david-sarah@jacaranda.org**20101024193409
105 Ignore-this: 3aee7f0677956cc6deaccb4d5b8e415f
106]
107[test_encodingutil.py: test_argv_to_unicode modified the wrong encoding variable. fixes #1214
108david-sarah@jacaranda.org**20101023035810
109 Ignore-this: e5f1f849931b96939facc53d93ff61c5
110]
111[docs/running.html: fix missing end-quote, and change frontends/ doc references to .rst.
112david-sarah@jacaranda.org**20101024171500
113 Ignore-this: 47c645a6595e1790b1d1adfa71af0e1d
114]
115[docs/running.html: 'tahoe create-client' now creates a node with storage disabled. Also change configuration.txt references to configuration.rst.
116david-sarah@jacaranda.org**20101024170431
117 Ignore-this: e5b048055494ba3505bb8a506610681c
118]
119[doc: add explanation of the motivation for the surprising and awkward API to erasure coding
120zooko@zooko.com**20101015060202
121 Ignore-this: 428913ff6e1bf5b393deffb1f20b949b
122]
123[setup: catch and log ValueError from locale.getdefaultlocale() in show-tool-versions.py
124zooko@zooko.com**20101015054440
125 Ignore-this: 827d91490562c32ed7cf6526dfded773
126 I got a bug report from Mathias Baert showing that locale.getdefaultlocale() raises an exception on his Mac OS X system. Heh.
127]
128[docs: update how-to-make-a-release doc with a few tweaks from the 1.8.0 process
129zooko@zooko.com**20101015054413
130 Ignore-this: ca5e9478531a3393792ae283239549dd
131]
132[docs: update NEWS ref: #1216
133zooko@zooko.com**20101015053719
134 Ignore-this: 2e0b92e4145d667cdf075e64b7965530
135]
136[docs: fix tab-vs-spaces, make some CLI examples <tt>/"literal", wrap some to
137Brian Warner <warner@lothar.com>**20101015060606
138 Ignore-this: eae08bdf0afb19a2fbf41c31e70a8122
139 80-cols, remove spurious whitespace. Add rst2html.py rule to Makefile.
140]
141[docs: add Peter Secor, Shawn Willden, and Terrell Russell as signatories to docs/backdoors.rst
142zooko@zooko.com**20101015053242
143 Ignore-this: c77adf819d664f673e17c4aaeb353f33
144]
145[docs: convert all .txt docs to .rst thanks to Ravi Pinjala
146zooko@zooko.com**20101015052913
147 Ignore-this: 178a5122423189ecfc45b142314a78ec
148 fixes #1225
149]
150[docs: add statement on our refusal to insert backdoors
151zooko@zooko.com**20101006051147
152 Ignore-this: 644d308319a7b80c4434bdff9760404a
153]
154[setup: add --multi-version to the "setup.py develop" command-line
155zooko@zooko.com**20101005182350
156 Ignore-this: 709155cc21caff29826b8d41a8c8d63d
157 fixes #530. I earlier tried this twice (see #530 for history) and then twice rolled it back due to some problems that arose. However, I didn't write down what the problems were in enough detail on the ticket that I can tell today whether those problems are still issues, so here goes the third attempt. (I did write down on the ticket that it would not create site.py or .pth files in the target directory with --multi-version mode, but I didn't explain why *that* was a problem.)
158]
159[setup: use execfile to access _auto_deps.py in its proper location of src/allmydata/ instead of copying it into place when setup.py is executed
160zooko@zooko.com**20100906055714
161 Ignore-this: c179b42672d775580afad40121f86812
162]
163[trivial: M-x whitespace-cleanup
164zooko@zooko.com**20100903144712
165 Ignore-this: 1bb764d11ac69b4a35ea091cfb13158a
166]
167[minor: remove unused interface declaration, change allmydata.org to tahoe-lafs.org in email address, fix wording in relnotes.txt
168zooko@zooko.com**20100930153708
169 Ignore-this: a452969228afed2774de375e29fa3048
170]
171[immutable/repairer.py: don't use the default happiness setting when repairing
172Kevan Carstensen <kevan@isnotajoke.com>**20100927200102
173 Ignore-this: bd704d9744b970849da8d46a16b8089a
174]
175[NEWS: note dependency updates to pycryptopp and pycrypto.
176david-sarah@jacaranda.org**20100924191207
177 Ignore-this: eeaf5c9c9104f24c450c2ec4482ac1ee
178]
179[TAG allmydata-tahoe-1.8.0
180zooko@zooko.com**20100924021631
181 Ignore-this: 494ca0a885c5e20c883845fc53e7ab5d
182]
183Patch bundle hash:
184a51cc7ad4c2b8030d353bd9dbc4be1f9287e0814