我在一个目录中有几个脚本,每个脚本都称为 bot 及其编号,从 1 到脚本的数量。
我想做的是通过终端(使用 Ubuntu)通过 1 个命令行运行所有脚本,我使用 forever
命令来运行脚本而不停止等等。
你能通过终端或者使用 Node js 脚本来实现吗?
是否还有其他命令(例如“forever”)可以为我完成此操作?
最佳答案
您可以通过命令行使用命令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": ""
}
]
然后您只需通过 forever
命令运行 JSON
文件即可。
示例:
forever start apps.json
您可以查看有关永远
的更多信息here .
关于node.js - 使用forever运行多个脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50756647/