The readme of Bazel-buildfarm says:
In general do not execute server binaries with bazel run, since bazel does not support running multiple targets.
This sounds like bazel run
is designed for local testing-purpose, not for productive servers where multiple jobs could run.
But I couldn't find a documentation showing how to run the bazel server instead. Older Dockerfiles run bazel build and then execute the generated jar-file with java. I tried this on my test machine and got the following error:
[vagrant@localhost bazel-buildfarm]$ java -Djava.util.logging.config.file=/config/logging.properties -jar bazel-bin/src/main/java/build/buildfarm/buildfarm-server.jar
no main manifest attribute, in bazel-bin/src/main/java/build/buildfarm/buildfarm-server.jar
The build before seems working:
[vagrant@localhost bazel-buildfarm]$ bazel build //src/main/java/build/buildfarm:buildfarm-server
Starting local Bazel server and connecting to it...
[...]
INFO: Analyzed target //src/main/java/build/buildfarm:buildfarm-server (94 packages loaded, 1623 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base /home/vagrant/.cache/bazel/_bazel_vagrant/277990f61896f4bac21fb997fb976b70/sandbox
Target //src/main/java/build/buildfarm:buildfarm-server up-to-date:
bazel-bin/src/main/java/build/buildfarm/buildfarm-server.jar
bazel-bin/src/main/java/build/buildfarm/buildfarm-server
INFO: Elapsed time: 11.180s, Critical Path: 0.61s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
And the jar file exists:
[vagrant@localhost bazel-buildfarm]$ l bazel-bin/src/main/java/build/buildfarm/buildfarm-server
-r-xr-xr-x. 1 vagrant vagrant 17K Nov 11 11:27 bazel-bin/src/main/java/build/buildfarm/buildfarm-server
I just installed bazel using CentOS repo with all dependencies (gcc gcc-c++) and cloned the git repo of bazel-buildfarm. With
bazel run //src/main/java/build/buildfarm:buildfarm-server $(pwd)/examples/server.config.example
the server could at least start successfull:
INFO: Analyzed target //src/main/java/build/buildfarm:buildfarm-server (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //src/main/java/build/buildfarm:buildfarm-server up-to-date:
bazel-bin/src/main/java/build/buildfarm/buildfarm-server.jar
bazel-bin/src/main/java/build/buildfarm/buildfarm-server
INFO: Elapsed time: 0.325s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Nov 12, 2019 3:08:13 PM build.buildfarm.server.BuildFarmServer <init>
INFO: buildfarm-server-c6735a2a-2c1b-473e-9d3e-14fe5d01c27d initialized
What am I doing wrong? Or is there another way how to run bazel in a production-ready way?
Platform: CentOS 7.7.1908 with Bazel 1.1.0 on Vagrant