From this Stack Overflow question, I realised you could keep a process running as a daemon in the background with popen
.
But when I tried this:
$daemon = popen('node nodeServer.js', 'r');
echo "Server started.\n";
It would break, and give me lots of Node.js-related errors.
Why is this? When I try node nodeServer.js
in command prompt, it works fine.
Here's the errors I got:
events.js:72
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at errnoException (net.js:901:11)
at Object.afterWrite (net.js:718:19)
Thanks.