Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: third_party/buildbot_7_12/buildbot/scripts/reconfig.py

Issue 12207158: Bye bye buildbot 0.7.12. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1
2 import os, signal, platform
3 from twisted.internet import reactor
4
5 from buildbot.scripts.logwatcher import LogWatcher, BuildmasterTimeoutError, \
6 ReconfigError
7
8 class Reconfigurator:
9 def run(self, config):
10 # Returns "Microsoft" for Vista and "Windows" for other versions
11 if platform.system() in ("Windows", "Microsoft"):
12 print "Reconfig (through SIGHUP) is not supported on Windows."
13 print "The 'buildbot debugclient' tool can trigger a reconfig"
14 print "remotely, but requires Gtk+ libraries to run."
15 return
16
17 basedir = config['basedir']
18 quiet = config['quiet']
19 os.chdir(basedir)
20 f = open("twistd.pid", "rt")
21 self.pid = int(f.read().strip())
22 if quiet:
23 os.kill(self.pid, signal.SIGHUP)
24 return
25
26 # keep reading twistd.log. Display all messages between "loading
27 # configuration from ..." and "configuration update complete" or
28 # "I will keep using the previous config file instead.", or until
29 # 10 seconds have elapsed.
30
31 self.sent_signal = False
32 lw = LogWatcher("twistd.log")
33 d = lw.start()
34 d.addCallbacks(self.success, self.failure)
35 reactor.callLater(0.2, self.sighup)
36 reactor.run()
37
38 def sighup(self):
39 if self.sent_signal:
40 return
41 print "sending SIGHUP to process %d" % self.pid
42 self.sent_signal = True
43 os.kill(self.pid, signal.SIGHUP)
44
45 def success(self, res):
46 print """
47 Reconfiguration appears to have completed successfully.
48 """
49 reactor.stop()
50
51 def failure(self, why):
52 if why.check(BuildmasterTimeoutError):
53 print "Never saw reconfiguration finish."
54 elif why.check(ReconfigError):
55 print """
56 Reconfiguration failed. Please inspect the master.cfg file for errors,
57 correct them, then try 'buildbot reconfig' again.
58 """
59 elif why.check(IOError):
60 # we were probably unable to open the file in the first place
61 self.sighup()
62 else:
63 print "Error while following twistd.log: %s" % why
64 reactor.stop()
65
66 def reconfig(config):
67 r = Reconfigurator()
68 r.run(config)
69
OLDNEW
« no previous file with comments | « third_party/buildbot_7_12/buildbot/scripts/logwatcher.py ('k') | third_party/buildbot_7_12/buildbot/scripts/runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698