How to close Node.js in the application?

Asked

Viewed 2,759 times

0

How do I stop a Node.JS application?


For example, in PHP, we have something like this:

exit;

Or:

die('Mensagem.');

Is there any way to stop the Node.js application this way (or similar), without having to use the Ctrl + C?

  • 1

    process.exit()?

1 answer

2


There are two ways through the object process:

(1) process.abort()

(2) process.exit(codigoDeSaida)

The first aborts the program on time, usually for abnormal things.

The second commands the Node to exit the program "gracefully" with an optional output code (which may mean an error).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.