Reputation: 31
I have a MEAN (Angular 2) app working on a Windows Server. I run my app with iisnode on the server. The app works fine, but at some point I try to spawn a child process with node (powershell.exe). Everything works fine locally (the powershell script executes successfully) but when I test it from the server URL, the child-process never spawns. I don't have any error message, the app just kinda pauses itself. When I run node.js from the command prompt with "node server.js" and I go to : http://myserver.com:9000 then the app works fine and the child-process spawns sucessfully.
I've tried to put the absolute path of powershell.exe but it doesn't work neither.
localhost:9000 : app works, child-process spawns ans works fine
myserver.com:9000 : app works, child-process spawns ans works fine
myserver.com/ : app works, child-process won't spawn, no error message
Here's my web.config file :
<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>
And here's the route .js from where I spawn the child-process :
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();
Upvotes: 1
Views: 497
Reputation: 31
Finally, it appeared that the powershell.exe was spawning correctly. However, the powershell script was supposed to open Powerpoint and do some actions within it. That part wouldn't work, and powershell would raise this error :
Insufficient memory to continue the execution of the program
This was solved by modifying DCOM config, as suggested here : How to deploy COM object Microsoft.Office.Interop to IIS so that my C# WCF service reference will work?
Upvotes: 2