子进程不会使用iisnode

时间:2017-07-06 09:18:15

标签: node.js powershell child-process windows-server iisnode

我有一个在Windows Server上运行的MEAN(Angular 2)应用程序。 我在服务器上使用iisnode运行我的应用程序。 该应用程序工作正常,但在某些时候,我尝试使用节点(powershell.exe)生成子进程。一切都在本地工作正常(powershell脚本成功执行)但是当我从服务器URL测试它时,子进程永远不会产生。 我没有任何错误消息,该应用程序只是暂停了一下。 当我使用“node server.js”从命令提示符运行node.js时,我转到: http://myserver.com:9000 ,然后应用程序运行良好,子进程成功生成。

我试图将 powershell.exe 的绝对路径放在一起,但它既不起作用。

localhost:9000 :app有效,子进程生成ans工作正常

myserver.com:9000 :app有效,子进程生成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();

1 个答案:

答案 0 :(得分:1)

最后,似乎powershell.exe正确生成了。 但是,powershell脚本应该打开Powerpoint并在其中执行一些操作。那部分不起作用,powershell会引发这个错误:

Insufficient memory to continue the execution of the program

这可以通过修改DCOM配置来解决,如下所示:How to deploy COM object Microsoft.Office.Interop to IIS so that my C# WCF service reference will work?