以生产就绪的方式执行bazel-buildfarm,而无需"bazel run" [英] Execute bazel-buildfarm in a production-ready way without "bazel run"
问题描述
In general do not execute server binaries with bazel run, since bazel does not support running multiple targets.
这听起来像bazel run
是为本地测试目的而设计的,而不是为可以运行多个作业的生产性服务器设计的.
但是我找不到文档来显示如何运行bazel服务器. 旧版Dockerfiles 运行bazel build,然后使用以下命令执行生成的jar文件Java的我在测试机上尝试了此操作,并收到以下错误:
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
并且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回购.使用
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
我做错了什么?还是有另一种方法可以以生产就绪的方式运行bazel?
What am I doing wrong? Or is there another way how to run bazel in a production-ready way?
平台:Vagrant上具有Bazel 1.1.0的CentOS 7.7.1908
Platform: CentOS 7.7.1908 with Bazel 1.1.0 on Vagrant
推荐答案
虽然我对buildfarm并不了解,但是您可能在使用Bazel运行的目标之间缺少双破折号(--
)及其论点.您的命令行可能应该是这样:
While I don't know anything specific about buildfarm, you're probably missing a double dash (--
) between the target you're running with Bazel and its arguments. Your command line should probably be this:
bazel run //src/main/java/build/buildfarm:buildfarm-server -- $(pwd)/examples/server.config.example
这篇关于以生产就绪的方式执行bazel-buildfarm,而无需"bazel run"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!