node.js - 永远运行几个脚本
问题描述
我在一个目录中有几个脚本,每个脚本都称为 bot 和它的编号,从 1 到脚本的编号。
我想做的是以某种方式通过终端通过 1 个命令行运行所有脚本(使用 Ubuntu),我使用forever
命令来运行脚本而不停止等等。
你可以通过终端或使用节点 js 脚本来实现吗?
有没有像永远这样的其他命令可以为我做这件事?
解决方案
您可以通过带有 command 的命令行使用它forever
。
您需要JSON
使用所需文件创建一个文件。
例子:
[
{
// App1
"uid": "app1", // ID of the script.
"append": true,
"watch": true,
"script": "bot1.js", // Name of the script
"sourceDir": "" // Where the script is located. If it's in the
// same location as the json file, leave it ""
},
{
// App2 = > Same as app1, just different script name.
"uid": "app2",
"append": true,
"watch": true,
"script": "bot2.js",
"sourceDir": ""
}
]
然后你只需要通过命令运行JSON
文件。forever
例子:
forever start apps.json
forever
您可以在此处查看更多信息。
推荐阅读
- mixed-models - GLMM 中的随机效应
- c++ - MSVC 编译器/链接器何时合成标量/向量删除析构函数
- android - 用于在 Facebook 上共享的图形 API
- javascript - npm 包在加载 vue js 组件时添加事件监听器
- python - 如何根据用户在下拉菜单中的选择重定向用户?
- vba - 运行时错误 3011,但不在调试模式下
- ssl - gRPC、NodeJS、mTLS istio 抛出 SSL 错误
- sharepoint-2013 - 将文档添加到库时如何将属性值设置为 URL 参数
- node.js - Jest mock 实现混淆
- android - 单击网站上的 url 后打开应用程序 Skype、iMessage、WhatsApp 出现问题?