bazel 远程工作者可部署 jar 不工作
bazel remote worker deployable jar not working
我在将 bazel-remote-worker 打包到可部署的 jar 中时遇到问题。
我运行以下命令:
bazel build //src/tools/remote_worker:remote_worker_deploy.jar
但是当我尝试 运行 jar 时,我得到了这个错误:
➜ bazel git:(master) ✗ java -jar remote_worker_deploy.jar --work_path=/tmp/test --listen_port=3030
*** Initializing in-memory cache server.
*** Not using remote cache. This should be used for testing only!
Exception in thread "main" java.lang.UnsatisfiedLinkError: no unix in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.google.devtools.build.lib.UnixJniLoader.loadJni(UnixJniLoader.java:28)
at com.google.devtools.build.lib.unix.NativePosixFiles.<clinit>(NativePosixFiles.java:136)
at com.google.devtools.build.lib.unix.UnixFileSystem.createDirectory(UnixFileSystem.java:309)
at com.google.devtools.build.lib.vfs.Path.createDirectory(Path.java:829)
at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParentsWithCache(FileSystemUtils.java:692)
at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParents(FileSystemUtils.java:652)
at com.google.devtools.build.remote.RemoteWorker.<init>(RemoteWorker.java:114)
at com.google.devtools.build.remote.RemoteWorker.main(RemoteWorker.java:621)
我启动它的唯一方法是 运行从 bazel-bin
:
中安装可执行文件
bazel-bin/src/tools/remote_worker/remote_worker --work_path=/tmp/test --listen_port=3030
我是 运行在 mac osx sierra 上最新的 运行ning bazel(目前 a3e26835890a543ff84cce90c879f9196ae06348
)。
我用 oracle-jdk-1.8.131
或 openjdk-1.8.91
试过了,结果都一样。
最终目标是创建一个 docker 图像 运行 这个罐子,但即使在 openjdk:8
这个罐子里面也是一样的...
显然我们没有将本机代码打包到部署 jar 中。实际上,我更愿意重构 RemoteWorker 以避免使用 Bazel 的大部分内部库,尽管这不太可能很快发生。您可以将 libunix.so 与部署 jar 一起发送并适当地设置 java.library.path 。或者,您可以在构建远程工作者 (bazel-bin/src/tools/remote_worker/remote_worker.runfiles/).
之后获取整个运行文件树
自提问以来,Bazel 源代码树中的路径发生了变化。现在获取 _deploy.jar 的构建命令如下。
bazel build src/tools/remote:worker_deploy.jar
mkdir -p /tmp/cas /tmp/cache /tmp/work
java -jar bazel-bin/src/tools/remote/worker_deploy.jar \
--cas_path /tmp/cas --disk_cache /tmp/cache --work_path /tmp/work
bazel build --spawn_strategy=remote \
--remote_cache=grpc://${IP}:8080 --remote_executor=grpc://${IP}:8080
我在将 bazel-remote-worker 打包到可部署的 jar 中时遇到问题。
我运行以下命令:
bazel build //src/tools/remote_worker:remote_worker_deploy.jar
但是当我尝试 运行 jar 时,我得到了这个错误:
➜ bazel git:(master) ✗ java -jar remote_worker_deploy.jar --work_path=/tmp/test --listen_port=3030
*** Initializing in-memory cache server.
*** Not using remote cache. This should be used for testing only!
Exception in thread "main" java.lang.UnsatisfiedLinkError: no unix in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.google.devtools.build.lib.UnixJniLoader.loadJni(UnixJniLoader.java:28)
at com.google.devtools.build.lib.unix.NativePosixFiles.<clinit>(NativePosixFiles.java:136)
at com.google.devtools.build.lib.unix.UnixFileSystem.createDirectory(UnixFileSystem.java:309)
at com.google.devtools.build.lib.vfs.Path.createDirectory(Path.java:829)
at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParentsWithCache(FileSystemUtils.java:692)
at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParents(FileSystemUtils.java:652)
at com.google.devtools.build.remote.RemoteWorker.<init>(RemoteWorker.java:114)
at com.google.devtools.build.remote.RemoteWorker.main(RemoteWorker.java:621)
我启动它的唯一方法是 运行从 bazel-bin
:
bazel-bin/src/tools/remote_worker/remote_worker --work_path=/tmp/test --listen_port=3030
我是 运行在 mac osx sierra 上最新的 运行ning bazel(目前 a3e26835890a543ff84cce90c879f9196ae06348
)。
我用 oracle-jdk-1.8.131
或 openjdk-1.8.91
试过了,结果都一样。
最终目标是创建一个 docker 图像 运行 这个罐子,但即使在 openjdk:8
这个罐子里面也是一样的...
显然我们没有将本机代码打包到部署 jar 中。实际上,我更愿意重构 RemoteWorker 以避免使用 Bazel 的大部分内部库,尽管这不太可能很快发生。您可以将 libunix.so 与部署 jar 一起发送并适当地设置 java.library.path 。或者,您可以在构建远程工作者 (bazel-bin/src/tools/remote_worker/remote_worker.runfiles/).
之后获取整个运行文件树自提问以来,Bazel 源代码树中的路径发生了变化。现在获取 _deploy.jar 的构建命令如下。
bazel build src/tools/remote:worker_deploy.jar
mkdir -p /tmp/cas /tmp/cache /tmp/work
java -jar bazel-bin/src/tools/remote/worker_deploy.jar \
--cas_path /tmp/cas --disk_cache /tmp/cache --work_path /tmp/work
bazel build --spawn_strategy=remote \
--remote_cache=grpc://${IP}:8080 --remote_executor=grpc://${IP}:8080