Welcome, Guest Login

Public Cloud Center

Graceful Shutdowns

Last Updated: Sep 08, 2015 02:55PM EDT

All Modulus projects receive notifications prior to something happening to them. This provides time for your application to gracefully react before an application is stopped, restarted, deployed, or any other action.

HTTP POST

Notifications are sent via HTTP POST. Applications must listen on port 63002 to receive these notifications.

Port: 63002
Method: POST
Route: /

Timeout

Once the message has been sent applications have up to 30 seconds before the action occurs. Applications can respond or end the graceful shutdown request sooner than 30 seconds to indicate they are done and allow Modulus to immediately complete the action.

Data Format

Data is posted as JSON with the following format:

{ "action": "[string]" }

Actions

"stop" User has stopped their application. Also sent to instances that will be removed during a scale down.
"restart" User has restarted their application.
"deploy" User has deployed a new version of their application.

Example

Below is a simple implementation of a graceful shutdown server using Express 4.

var express = require('express');
var bodyParser = require('body-parser');
var shutdownApp = express();

shutdownApp.use(bodyParser.json());

shutdownApp.post('/', function(req, res) {
  // Do whatever cleanup is required and end the request when done.
  // Using setTimeout here to simulate an async cleanup operation.
  setTimeout(function() {
    res.end();
  }, 5000);
});

// Listen on the graceful shutdown port.
shutdownApp.listen(63002);

Exiting

It's important not to exit your own process during one of these events. Our system will send the kill signal to your process at the appropriate time. If you kill your own process, it will be treated like a crash, brought back, and then killed again after the graceful shutdown notification is complete.

Go to top
 

Contact Us

    Our Support Policy
    Submit a Support Request

  • Public Cloud Support Hours
    9am-5pm EST Mon-Fri
    Outside of these hours response times may be up to 24hrs.


    Submit a support ticket by clicking 'status and support' icon on the left side of this page.



help@hellotangible.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en_us/portal/articles/autocomplete