我有一个在Windows Server上工作的MEAN(Angular 2)应用程序。 我在服务器上用iisnode运行我的应用程序。 该应用程序工作正常,但在某些时候我尝试用节点(powershell.exe)产生子进程。本地一切正常(powershell脚本执行成功),但是当我从服务器URL测试它时,子进程永远不会产生。 我没有任何错误消息,应用程序只是有点暂停。 当我使用“node server.js”从命令提示符运行node.js,并且我转到:http://myserver.com:9000然后该应用程序正常工作,并且子进程生成成功。子进程不会与iisnode产生
我试图把powershell.exe的绝对路径,但它也不工作。
本地主机:9000:应用的工作方式,对儿童的过程产卵ANS工作正常
myserver.com:9000:应用的工作方式,对儿童的过程产卵ANS工作正常
myserver.com/:应用的工作方式,对儿童过程中不会产卵,没有错误消息
这里是我的的web.config文件:
<configuration>
<system.webServer>
<!-- indicates that the hello.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="server">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
而这里的路线的.js从我产卵子过程:
child = spawn("powershell.exe",[`some commands`]);
child.stdout.on("data",function(data){
console.log("Powershell Data: " + data);
});
child.stderr.on("data",function(data){
console.log("Powershell Errors: " + data);
});
child.on("exit",function(){
console.log("Powershell Script finished");
//some other commands
});
child.stdin.end();