1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import os
18 import signal
19 import platform
20 import sys
21 from twisted.internet import reactor
22
23 from buildbot.scripts.logwatcher import LogWatcher, BuildmasterTimeoutError, \
24 ReconfigError
25
27
28 rc = 0
29
30 - def run(self, config):
31
32 if platform.system() in ("Windows", "Microsoft"):
33 print "Reconfig (through SIGHUP) is not supported on Windows."
34 print "The 'buildbot debugclient' tool can trigger a reconfig"
35 print "remotely, but requires Gtk+ libraries to run."
36 return
37
38 basedir = config['basedir']
39 quiet = config['quiet']
40 os.chdir(basedir)
41 f = open("twistd.pid", "rt")
42 self.pid = int(f.read().strip())
43 if quiet:
44 os.kill(self.pid, signal.SIGHUP)
45 return
46
47
48
49
50
51
52 self.sent_signal = False
53 lw = LogWatcher("twistd.log")
54 d = lw.start()
55 d.addCallbacks(self.success, self.failure)
56 reactor.callLater(0.2, self.sighup)
57 reactor.run()
58 sys.exit(self.rc)
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 reactor.stop()
72
74 self.rc = 1
75 if why.check(BuildmasterTimeoutError):
76 print "Never saw reconfiguration finish."
77 elif why.check(ReconfigError):
78 print """
79 Reconfiguration failed. Please inspect the master.cfg file for errors,
80 correct them, then try 'buildbot reconfig' again.
81 """
82 elif why.check(IOError):
83
84 self.sighup()
85 else:
86 print "Error while following twistd.log: %s" % why
87 reactor.stop()
88