For service node from within js

0

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

How to do this?

    
asked by anonymous 26.01.2018 / 14:17

1 answer

1

Call the method process of the global object exit:

Documentation

  

process.exit ([code])

     

Terminates the process with the specified code. If omitted, exit uses the code 'success' 0.

     

To exit with a 'failed' code:

     

process.exit (1);

     

The shell that ran the node should see the exit code as 1.

    
26.01.2018 / 14:22