Shutdown hook for Node JS flex env?

26 views
Skip to first unread message

Shai Ben-Tovim

unread,
Mar 20, 2018, 9:01:37 AM3/20/18
to Google App Engine
Hi,

Is there a way to configure a shutdown hook in the node js flex environment? 
Goal is to run some code when instance(s) is(are) shutdown/recycled. I know there's an option for a shutdown hook in some of the standard env's (Python) and wanted to know what the equivalent option is for node js - couldn't find anything in the docs.

Thanks

Jordan (Cloud Platform Support)

unread,
Mar 20, 2018, 1:20:27 PM3/20/18
to Google App Engine
As per the documentation App Engine sends a SIGTERM signal to your application container running within the instance to notify your application that it is about to be shutdown.  

You can read from the stdin in Node.js to run a function once the signal is received. Normally you should have 30 seconds to receive the signal and complete the function, but this is not guaranteed and may be cut short due to unforeseen network and/or resource issues as explained in the documentation. 

- Note that Google Groups is for general product discussions. For technical support in setting up the shutdown hook it is recommended post your detailed questions to Stack Overflow using the supported Cloud tags. 
Reply all
Reply to author
Forward
0 new messages