~ubuntu-branches/ubuntu/trusty/buildbot/trusty-proposed

« back to all changes in this revision

Viewing changes to buildbot/master.py

  • Committer: Package Import Robot
  • Author(s): Andriy Senkovych
  • Date: 2013-10-10 13:22:47 UTC
  • mfrom: (1.2.10)
  • Revision ID: package-import@ubuntu.com-20131010132247-m622rpa3yemt62te
Tags: 0.8.8-1
* New upstream release
* Remove text-client.patch (applied upstream)
* Add bash-completion. Thanks to Elmir Jagudin
* debian/control: add Vcs-* fields

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from buildbot.process.users import users
41
41
from buildbot.process.users.manager import UserManagerManager
42
42
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE
 
43
from buildbot.util.eventual import eventually
43
44
from buildbot import monkeypatches
44
45
from buildbot import config
45
46
 
80
81
 
81
82
        # loop for polling the db
82
83
        self.db_loop = None
 
84
        # db configured values
 
85
        self.configured_db_url = None
 
86
        self.configured_poll_interval = None
83
87
 
84
88
        # configuration / reconfiguration handling
85
89
        self.config = config.MasterConfig()
168
172
            try:
169
173
                self.config = config.MasterConfig.loadConfig(self.basedir,
170
174
                                                        self.configFileName)
 
175
 
171
176
            except config.ConfigErrors, e:
172
177
                log.msg("Configuration Errors:")
173
178
                for msg in e.errors:
191
196
 
192
197
            if hasattr(signal, "SIGHUP"):
193
198
                def sighup(*args):
194
 
                    _reactor.callLater(0, self.reconfig)
 
199
                    eventually(self.reconfig)
195
200
                signal.signal(signal.SIGHUP, sighup)
196
201
 
 
202
            if hasattr(signal, "SIGUSR1"):
 
203
                def sigusr1(*args):
 
204
                    _reactor.callLater(0, self.botmaster.cleanShutdown)
 
205
                signal.signal(signal.SIGUSR1, sigusr1)
 
206
 
197
207
            # call the parent method
198
208
            yield defer.maybeDeferred(lambda :
199
209
                    service.MultiService.startService(self))
208
218
 
209
219
        log.msg("BuildMaster is running")
210
220
 
211
 
 
 
221
    @defer.inlineCallbacks
212
222
    def stopService(self):
 
223
        if self.running:
 
224
            yield service.MultiService.stopService(self)
213
225
        if self.db_loop:
214
226
            self.db_loop.stop()
215
227
            self.db_loop = None
286
298
 
287
299
 
288
300
    def reconfigService(self, new_config):
289
 
        if self.config.db['db_url'] != new_config.db['db_url']:
 
301
        if self.configured_db_url is None:
 
302
            self.configured_db_url = new_config.db['db_url']
 
303
        elif (self.configured_db_url != new_config.db['db_url']):
290
304
            config.error(
291
305
                "Cannot change c['db']['db_url'] after the master has started",
292
306
            )
293
307
 
294
308
        # adjust the db poller
295
 
        if (self.config.db['db_poll_interval']
 
309
        if (self.configured_poll_interval
296
310
                != new_config.db['db_poll_interval']):
297
311
            if self.db_loop:
298
312
                self.db_loop.stop()
299
313
                self.db_loop = None
300
 
            poll_interval = new_config.db['db_poll_interval']
301
 
            if poll_interval:
 
314
            self.configured_poll_interval = new_config.db['db_poll_interval']
 
315
            if self.configured_poll_interval:
302
316
                self.db_loop = task.LoopingCall(self.pollDatabase)
303
 
                self.db_loop.start(poll_interval, now=False)
 
317
                self.db_loop.start(self.configured_poll_interval, now=False)
304
318
 
305
319
        return config.ReconfigurableServiceMixin.reconfigService(self,
306
320
                                            new_config)