Search code examples
node.jsterminalbazel

How to Stop Node.Js Process Started by Bazel


bazel run //services/server

Starts a Node.Js Server. But after the server started, I can't stop it by pressing CTRL + C. How can I stop the process? (I am using Ubuntu)

You can try it yourself: https://github.com/flolude/minimal-bazel-monorepo

Terminal

P.S.: I also cannot find the process via ps -ef.


Solution

  • If you are using a locally installed docker, you can run 'docker ps -a' to see all of your running images. Bazel pushes your image to your local docker repo, and tags it with 'bazel' I believe. You can use the docker kill command to kill your container.

    For what it's worth, ctrl-c exits the run command for me in ubuntu 18.04 with bazel 1.x, using the bash shell. (I never checked if it actually killed my container tho.)

    Here is a ticket that might be relevant: https://github.com/bazelbuild/bazel/issues/3519

    In fact, the above issue is referenced by rules_docker here: https://github.com/bazelbuild/rules_docker/blob/bb8da501955e5f7c1f704c50c0e4fce0193b2b2e/java/image.bzl#L406