|
| 1 | +import fnmatch |
| 2 | +import os |
| 3 | +import sys |
| 4 | + |
| 5 | +from twisted.application import service |
| 6 | +from twisted.python.log import FileLogObserver |
| 7 | +from twisted.python.log import ILogObserver |
| 8 | + |
| 9 | +from buildbot_worker.bot import Worker |
| 10 | + |
| 11 | +# setup worker |
| 12 | +basedir = os.path.abspath(os.path.dirname(__file__)) |
| 13 | +application = service.Application('buildbot-worker') |
| 14 | + |
| 15 | + |
| 16 | +application.setComponent(ILogObserver, FileLogObserver(sys.stdout).emit) |
| 17 | +# and worker on the same process! |
| 18 | +buildmaster_host = os.environ.get("BUILDMASTER", 'localhost') |
| 19 | +port = int(os.environ.get("BUILDMASTER_PORT", 9989)) |
| 20 | +workername = os.environ.get("WORKERNAME", 'docker') |
| 21 | +passwd = os.environ.get("WORKERPASS") |
| 22 | + |
| 23 | +# delete the password from the environ so that it is not leaked in the log |
| 24 | +blacklist = os.environ.get("WORKER_ENVIRONMENT_BLACKLIST", "WORKERPASS").split() |
| 25 | +for name in list(os.environ.keys()): |
| 26 | + for toremove in blacklist: |
| 27 | + if fnmatch.fnmatch(name, toremove): |
| 28 | + del os.environ[name] |
| 29 | + |
| 30 | +keepalive = 600 |
| 31 | +umask = None |
| 32 | +maxdelay = 300 |
| 33 | +allow_shutdown = None |
| 34 | +maxretries = 10 |
| 35 | + |
| 36 | +s = Worker(buildmaster_host, port, workername, passwd, basedir, |
| 37 | + keepalive, umask=umask, maxdelay=maxdelay, |
| 38 | + allow_shutdown=allow_shutdown, maxRetries=maxretries, unicode_encoding='utf-8') |
| 39 | +s.setServiceParent(application) |
0 commit comments