3

I am running Buildbot version 0.8.8 on Windows7.

I have the configuration (master.cfg) file which creates all the builders using a small trick. I read a XML file from the subversion which lists all the steps for the builders. Something like:

<Builder name="BuilderA" description="Builds the A project">
    <Command name="Clean">-v -t realclean -p my\\projA</Command>
    <Command name="Release">-v -t release -p my\\projA</Command>
</Builder>

<Builder name="BuilderB" description="Builds the B project">
    <Command name="Clean">-v -t realclean -p my\\projB</Command>
    <Command name="Release">-v -t release -p my\\projB</Command>
</Builder>

The idea is that any developer can change the XML file in the subversion and then buildmaster could be restarted in order to have the new buildbot configuration.

I start the buildbot using the command: buildbot start C:\master_dir

The issue I am facing is that when I am trying to restart the buildbot it complains that buildmaster not running. Digging deep into the sources I found that it fails in buildbot\scripts\stop.py:34 when trying to open the twisted.pid file.

pidfile = os.path.join(basedir, 'twistd.pid')
try:
    with open(pidfile, "rt") as f:
        pid = int(f.read().strip())
except:
    if not config['quiet']:
        print "buildmaster not running"
    return 0

I have no idea what is this twisted.pid file and why buildbot is looking for this? Any help or ideas will be appreciated. Thanks.

sk11
  • 1,779
  • 1
  • 17
  • 29
  • That bare `except` is terrible style and might be obscuring some other error condition. Try changing the code to report the actual error that's happening and report this bad error handling code upstream so it can be fixed properly. – Jean-Paul Calderone Nov 29 '14 at 13:23
  • 1
    @Jean-PaulCalderone The code I quoted is buildbot's package code. Its not something written by me. I quoted it to make the question more clear and to show where the actual error is happening. – sk11 Dec 02 '14 at 17:41
  • Indeed - but it is still bad code that should be fixed. :) And in fixing it, it's possible you will reveal the underlying cause of this failure. – Jean-Paul Calderone Dec 03 '14 at 00:13

2 Answers2

1

I am experiencing the same issue. It seems on windows the file twistd.pid is not created. I am not sure where the bug comes from, but I reported the bug to buildbot team: http://trac.buildbot.net/ticket/3512

As workaround, I now added in my master.cfg:

import os
if not os.path.exists("twistd.pid"):
    with open("twistd.pid", "w") as pidfile:
        pidfile.write("{}".format(os.getpid()))

EDIT: Actually, it seems the PID file is not deleted after stopping... So I try with this more:

else:
    realpid = os.getpid()
    filepid = 0
    with open("twistd.pid", "r") as pidfile:
        filepid = int(pidfile.read())
    if filepid == 0 or filepid != realpid:
        with open("twistd.pid", "w") as pidfile:
            pidfile.write("{}".format(realpid))

It seems to work, but you would get an error if you try to stop buildbot when it is really not running, as the PID file would yield a wrong PID and it would try to kill it.

XonqNopp
  • 101
  • 8
0

The information you have so far provided falls short of showing that anything is actually wrong.

twistd.pid is the buildmaster's process-id file. Its existence indicates that the buildmaster is running. Its absence indicates that the buildmaster is not running.

Restarting the buildmaster means stopping it then starting it. Stopping it makes buildbot check for the buildmaster's pid file. If there is no pid file, then it informs you that the buildmaster is not running, and proceeds to start it.

So:-

  • This message is quite in order unless you know that the buildmaster is running when you restart it and observe this message. Do you know that?

  • The message is harmless information, unless the buildmaster also fails to start. Do you know that it fails to start?

If you know that the buildmaster was running when buildbot said it was not, and that it failed to start when you tried to restart it, then the first thing one would like to know is: Exactly what command did you run to restart the buildmaster and in what directory did you run it?

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
  • Hi Mike, Thanks for the inputs. Yes the buildmaster is running after I issue the `start` command. I can verify it on the html status waterfall webpage. So buildmaster is running for sure. Second, I ran `buildbot restart C:\master_dir`, in the same directory where buildmaster is supposed to be running. And I checked the directory but I didn't find any twisted.pid file. – sk11 Nov 28 '14 at 16:00