如何 运行 节点服务器上的 .bat 文件?
How to run a .bat file on a node server?
我想知道您是否可以自动重启使用 node.js 制作的服务器。我的想法是 运行 通过节点重新启动服务器的 .bat 文件。
可以吗?
您可以使用exec
如下
const { exec } = require('child_process');
exec('shutdown -s -t 0') ; // change command according to your system
检查此问题以获取有关 exec
的更多详细信息
Execute a command line binary with Node.js
通常可以通过调用 shutdown.exe
来批量重启服务器
您可以使用 nodejs 执行任何文件。 NodeJS 文档是 here.
我想知道您是否可以自动重启使用 node.js 制作的服务器。我的想法是 运行 通过节点重新启动服务器的 .bat 文件。 可以吗?
您可以使用exec
如下
const { exec } = require('child_process');
exec('shutdown -s -t 0') ; // change command according to your system
检查此问题以获取有关 exec
的更多详细信息Execute a command line binary with Node.js
通常可以通过调用 shutdown.exe
来批量重启服务器您可以使用 nodejs 执行任何文件。 NodeJS 文档是 here.