This post shows how to create Service unit files for systemd which let start and restart BuildBot on Linux distributions using systemd. This unit files depend on a working VirtualEnv installation of BuildBot in the /srv/buildbot directory. It also runs BuildBut with the user/group “buildbot”. Two unit files are necessary to start the master and slave instance respectively. Instead of using the buildbot/buildslave commands, the twistd binary is executed directly in foreground. twistd is an application/service framework for Python, which BuildBot makes use of.
buildbot-master.service
[Unit] Description=BuildBot master service After=network.target [Service] User=buildbot Group=buildbot WorkingDirectory=/srv/buildbot/ Environment="VIRTUAL_ENV=/srv/buildbot/sandbox" "PATH=/srv/buildbot/sandbox/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" ExecStart=/srv/buildbot/sandbox/bin/twistd \ --nodaemon --no_save --pidfile= --python=master/buildbot.tac [Install] WantedBy=multi-user.target
buildbot-slave.service
[Unit] Description=BuildBot slave service After=network.target [Service] User=buildbot Group=buildbot WorkingDirectory=/srv/buildbot/ Environment="VIRTUAL_ENV=/srv/buildbot/sandbox" "PATH=/srv/buildbot/sandbox/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" ExecStart=/srv/buildbot/sandbox/bin/twistd \ --nodaemon --no_save --pidfile= --python=slave/buildbot.tac [Install] WantedBy=buildbot-master.service
Now, let’s enable the services and start them. Due to the WantedBy configuration, systemd will start the build slave automatically when the buildbot-master.service gets started.
# systemctl enable buildbot-master.service # systemctl enable buildbot-slave.service # systemctl start buildbot-master.service
Note that BuildBot will end up with a rather clean environment, which might be too spartan, depending on the commands running. The Environment configuration above allows to extend globally for the master and slave instance, in case needed.
HOME=/home/buildbot
LANG=en_US.UTF-8
LOGNAME=buildbot
PATH=/srv/buildbot/sandbox/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PWD=/srv/buildbot/slave/buld-job/build
SHELL=/bin/bash
USER=buildbot
VIRTUAL_ENV=/srv/buildbot/sandbox
Related resources:
0 Comments.