2017-07-06 226 views
0

我有一個在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(); 

回答