Bazel Watcher not Terminating Node Process (Error: Listen EADDRINUSE: address already in use :::3000)
Bazel Watcher not Terminating Node Process (Error: Listen EADDRINUSE: address already in use :::3000)
我有一个 Bazel BUILD 文件 nodejs_image
:
package(default_visibility = ["//visibility:public"])
load("@npm_bazel_typescript//:index.bzl", "ts_library")
ts_library(
name = "lib",
srcs = glob(
include = ["**/*.ts"],
exclude = ["**/*.spec.ts"]
),
deps = [
"//packages/enums/src:lib",
"//packages/hello/src:lib",
"@npm//faker",
"@npm//@types/faker",
"@npm//express",
"@npm//@types/express",
"@npm//cors",
],
)
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
nodejs_image(
name = "server",
data = [":lib"],
entry_point = ":index.ts",
)
启动一个简单的 Express Node.Js 服务器:
app.listen(3000, () => console.log('listening on port 3000'));
当我运行
ibazel run //services/server/src:server
服务器启动正常。但是当我更改一些代码并且 Bazel Watcher 重新启动时,我收到此错误:
Error: listen EADDRINUSE: address already in use :::3000
因此,之前的 Node.Js 进程没有被终止,端口仍在使用中。
我是否必须在我的 Node.Js 应用程序中处理终止?
或者是否有其他方法 运行 Node.Js 使用 Bazel Watcher 编码?
还是 Bazel Watcher 的问题?
你可以自己试试:https://github.com/flolude/minimal-bazel-monorepo/tree/f23b960b57a94abbb5cbc13853b3e8ec4a1997ab
正如 @Toxicable 所述,我已将 nodejs_image
更改为 nodejs_binary
,如下所示:
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
nodejs_binary(
name = "server",
data = [":lib"],
entry_point = ":index.ts",
)
解决了这个问题。
我有一个 Bazel BUILD 文件 nodejs_image
:
package(default_visibility = ["//visibility:public"])
load("@npm_bazel_typescript//:index.bzl", "ts_library")
ts_library(
name = "lib",
srcs = glob(
include = ["**/*.ts"],
exclude = ["**/*.spec.ts"]
),
deps = [
"//packages/enums/src:lib",
"//packages/hello/src:lib",
"@npm//faker",
"@npm//@types/faker",
"@npm//express",
"@npm//@types/express",
"@npm//cors",
],
)
load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
nodejs_image(
name = "server",
data = [":lib"],
entry_point = ":index.ts",
)
启动一个简单的 Express Node.Js 服务器:
app.listen(3000, () => console.log('listening on port 3000'));
当我运行
ibazel run //services/server/src:server
服务器启动正常。但是当我更改一些代码并且 Bazel Watcher 重新启动时,我收到此错误:
Error: listen EADDRINUSE: address already in use :::3000
因此,之前的 Node.Js 进程没有被终止,端口仍在使用中。
我是否必须在我的 Node.Js 应用程序中处理终止?
或者是否有其他方法 运行 Node.Js 使用 Bazel Watcher 编码?
还是 Bazel Watcher 的问题?
你可以自己试试:https://github.com/flolude/minimal-bazel-monorepo/tree/f23b960b57a94abbb5cbc13853b3e8ec4a1997ab
正如 @Toxicable 所述,我已将 nodejs_image
更改为 nodejs_binary
,如下所示:
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary")
nodejs_binary(
name = "server",
data = [":lib"],
entry_point = ":index.ts",
)
解决了这个问题。