For Node service from within js

Asked

Viewed 28 times

0

Well I need to finish a Node process from within js itself. What happens is that I have a cron that executes a command node meu_arquivo.js and accurate within this meu_arquivo.js end the Node so that it is not open.

How to do this ?

  • I’ve never used it, but there’s Tree-Kill

  • @Lucascosta found something of Ode’s. I answered my question there

1 answer

3


Call the method process of the global object Exit:

Documentation

process.Exit ([code])

Ends the process with the specified code. If omitted, Exit uses the 'success' code 0.

To come out with a 'fail code'':

process.Exit(1);

The shell that executed the node should see the output code as 1.

Browser other questions tagged

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