Ticket #226: nofailRestart.diff

File nofailRestart.diff, 1.8 kB (added by bhearsum, 8 months ago)

make 'buildbot restart' work when buildbot is not running

  • old-upstream-buildbot-mirror/buildbot/interfaces.py

    old new  
    1414class BuildSlaveTooOldError(Exception): 
    1515    pass 
    1616 
     17# other exceptions 
     18class BuildbotNotRunningError(Exception): 
     19    pass 
     20 
    1721class IChangeSource(Interface): 
    1822    """Object which feeds Change objects to the changemaster. When files or 
    1923    directories are changed and the version control system provides some 
  • old-upstream-buildbot-mirror/buildbot/scripts/runner.py

    old new  
    66import traceback 
    77from twisted.python import usage, util, runtime 
    88 
     9from buildbot.interfaces import BuildbotNotRunningError 
     10 
    911# this is mostly just a front-end for mktap, twistd, and kill(1), but in the 
    1012# future it will also provide an interface to some developer tools that talk 
    1113# directly to a remote buildmaster (like 'try' and a status client) 
     
    457459    basedir = config['basedir'] 
    458460    quiet = config['quiet'] 
    459461    os.chdir(basedir) 
    460     f = open("twistd.pid", "rt") 
     462    try: 
     463        f = open("twistd.pid", "rt") 
     464    except: 
     465        raise BuildbotNotRunningError 
    461466    pid = int(f.read().strip()) 
    462467    signum = getattr(signal, "SIG"+signame) 
    463468    timer = 0 
     
    483488def restart(config): 
    484489    quiet = config['quiet'] 
    485490    from buildbot.scripts.startup import start 
    486     stop(config, wait=True) 
     491    try: 
     492        stop(config, wait=True) 
     493    except BuildbotNotRunningError: 
     494        pass 
    487495    if not quiet: 
    488496        print "now restarting buildbot process.." 
    489497    start(config)