node.js - 将 KillAll 发送到多 Node 进程并等待响应

标签 node.js linux bash shell

我正在创建一个脚本,从 git 存储库中拉取一些内容。

但首先我想发送一个 SIGUSR1 到我在机器上运行的多个 Node ,一旦所有进程停止我将继续进行 git pull

基本上我会跑

killall -s SIGUSR1 node

因为我的 Node 正在执行无限循环,所以我想拦截此信号并在我知道它不会影响任何数据的循环部分中终止。

所以当所有 Node 都停止时我会继续

但是我如何在执行 git pull 并重新开始 Node 循环之前等待所有 Node 进程干净地退出

最佳答案

来自 man killall:

    -w, --wait
           Wait for all killed processes to die.  killall checks once  per  second  if  any  of  the
           killed  processes  still  exist and only returns if none are left.  Note that killall may
           wait forever if the signal was ignored, had no effect, or if the process stays in  zombie
           state.

关于node.js - 将 KillAll 发送到多 Node 进程并等待响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47980136/

相关文章:

java - 通过maven编译议程代码错误: AgendaSample1Impl. java :[47, 81]错误: diamond operator is not supported in -source 1. 5

javascript - Node ,如何使同步代码超时?

javascript - Firebase 的云函数错误 : getaddrinfo ENOTFOUND

linux - 如何查找某个进程中使用的文件和文件夹?

bash - 我如何回显/打印来自 bash 变量的特定行

python - Open Stack 端点 API 请求 OS X

python - 使用 Shell 脚本从 python 获取返回值

node.js - Mongoose 如何根据自定义字段更新(如果存在)。否则插入

node.js - NodeJS 上的 Cassandra 客户端错误

Linux 高可用性与 Apache Hadoop