以生产就绪的方式执行bazel-buildfarm,而无需“ bazel run”

时间:2019-11-12 17:01:05

标签: java jar bazel

readme of Bazel-buildfarm说:

In general do not execute server binaries with bazel run, since bazel does not support running multiple targets.

这听起来像bazel run是为本地测试目的而设计的,而不是针对可以运行多个作业的生产服务器。 但是我找不到文档来显示如何运行bazel服务器。 Older Dockerfiles运行bazel build,然后使用Java执行生成的jar文件。我在测试机上尝试了此操作,并收到以下错误:

[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

之前的版本似乎可以正常工作:

[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

并且jar文件存在:

[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

我刚刚使用具有所有依赖项(gcc gcc-c ++)的CentOS回购安装了bazel,并克隆了bazel-buildfarm的git回购。使用

bazel run //src/main/java/build/buildfarm:buildfarm-server $(pwd)/examples/server.config.example

服务器至少可以成功启动:

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

我在做什么错?还是有另一种方法可以以生产就绪的方式运行bazel?

平台:Vagrant上带有Bazel 1.1.0的CentOS 7.7.1908

0 个答案:

没有答案