Imp API for On Deployments?

Can we catch the event of a new deployment being pushed? I require some steps before powering down the device.

Yes, see server.onshutdown():

Bringing this up again as I have tested the server.onshutdown() with server.restarts()'s.

I’m not getting any triggers on my server.onshutdown() handler which simply logs a message and sets a flag.

function shutdownCB(reason) {
logger.log("onshutdown(): Got a reboot request.");

switch(reason) {

logger.log("onshutdown(): New Squirrel code is available.");

logger.log("onshutdown(): New impOS firmware is available.");

logger.log("onshutdown(): A restart is requested for some other reason.");
Device.StopI2CReboot = true;


Your first sentence implies that you’re calling server.restart() in the expectation that this will trigger the callback registered with server.onshutdown(). This is not how the system works.

The callback will be triggered by impOS on receipt of a message from the impCloud. Your code can then determine what update — impOS or Squirrel code — is pending and take action. You callback should then call server.restart() to begin the update process.

When you call server.restart() is up to you. You can do it straight away or go and run some of your own code first (eg. to save application state), but you need to do it at some point.

You can, of course, call server.restart() at any time irrespective of pending updates, but it will never cause the server.onshutdown() to be triggered as it is supposed to follow the execution of the callback, not precede it.