Grokking Node.js
Vote

0% completed

​

Using PM2 for Process Management and Auto-Restart

A Node.js server started with node server.js stops permanently the first time an exception is not caught by any of its error handling. The server below throws inside its request handler, as an example of any bug that the tests did not catch:

const http = require("http"); const server = http.createServer((req, res) => { throw new Error("Unexpected error!"); }); server.listen(4000, () => { console.log(`Server ${process.pid} is running on port 4000`); });

Save it as crash.js and start it with node crash.js

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content