Right now I have a nodeJS script that sets up a database for me. Whenever I run it in my command line, I need to ctrl-C to exit the script. I'm assuming that there is some kind of command within nodeJS to have it exit on its own when it's done, but I can't seem to find any such command by doing searches on the interwebz. Does anybody happen to know if this is possible, and if so, what the command is?
现在我有一个nodeJS脚本为我设置数据库。每当我在命令行中运行它时,我需要ctrl-C来退出脚本。我假设nodeJS中有某种命令让它在完成后自行退出,但我似乎无法通过在interwebz上搜索找到任何这样的命令。有没有人碰巧知道这是否可能,如果可能,该命令是什么?
2 个解决方案
#1
10
you can exit the script by calling process.exit() (see http://nodejs.org/docs/v0.5.4/api/process.html#process.exit)
您可以通过调用process.exit()退出脚本(请参阅http://nodejs.org/docs/v0.5.4/api/process.html#process.exit)
#2
1
you should be using process.exit(). You can pass any status also which will be displayed on the console log.
你应该使用process.exit()。您也可以传递将在控制台日志中显示的任何状态。
#1
10
you can exit the script by calling process.exit() (see http://nodejs.org/docs/v0.5.4/api/process.html#process.exit)
您可以通过调用process.exit()退出脚本(请参阅http://nodejs.org/docs/v0.5.4/api/process.html#process.exit)
#2
1
you should be using process.exit(). You can pass any status also which will be displayed on the console log.
你应该使用process.exit()。您也可以传递将在控制台日志中显示的任何状态。