Process
Learn how to use the Node.js process object to manage the current runtime, handle critical events like exit, beforeExit, and uncaughtException, and utilize common methods and streams for better application control.
We'll cover the following...
We'll cover the following...
The process object
The process object is a global that allows us to control the current process. It also has methods that can provide useful information about the process. Being an instance of the EventEmitter class, it has a few important events that we should know about. Let’s take a look at them.
exit and beforeExit
These two events can be very useful at times. Consider the scenario:
- You wish to save your program progress to the cloud once it is done processing. The
beforeExitevent is perfect for this job. It isfired emitted