1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from __future__ import with_statement
17
18
19 import os
20 import signal
21 import platform
22 from twisted.internet import reactor
23
24 from buildbot.scripts.logwatcher import LogWatcher, BuildmasterTimeoutError, \
25 ReconfigError
26 from buildbot.util import in_reactor
29
30 rc = 0
31
32 - def run(self, basedir, quiet):
33
34 if platform.system() in ("Windows", "Microsoft"):
35 print "Reconfig (through SIGHUP) is not supported on Windows."
36 print "The 'buildbot debugclient' tool can trigger a reconfig"
37 print "remotely, but requires Gtk+ libraries to run."
38 return
39
40 with open(os.path.join(basedir, "twistd.pid"), "rt") as f:
41 self.pid = int(f.read().strip())
42 if quiet:
43 os.kill(self.pid, signal.SIGHUP)
44 return
45
46
47
48
49
50
51 self.sent_signal = False
52 reactor.callLater(0.2, self.sighup)
53
54 lw = LogWatcher(os.path.join(basedir, "twistd.log"))
55 d = lw.start()
56 d.addCallbacks(self.success, self.failure)
57 d.addBoth(lambda _ : self.rc)
58 return d
59
61 if self.sent_signal:
62 return
63 print "sending SIGHUP to process %d" % self.pid
64 self.sent_signal = True
65 os.kill(self.pid, signal.SIGHUP)
66
68 print """
69 Reconfiguration appears to have completed successfully.
70 """
71
73 self.rc = 1
74 if why.check(BuildmasterTimeoutError):
75 print "Never saw reconfiguration finish."
76 elif why.check(ReconfigError):
77 print """
78 Reconfiguration failed. Please inspect the master.cfg file for errors,
79 correct them, then try 'buildbot reconfig' again.
80 """
81 elif why.check(IOError):
82
83 self.sighup()
84 else:
85 print "Error while following twistd.log: %s" % why
86
93