Child pages
  • Maintenance Mode

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

These operations can be performed through the maintenance plugin, which is available since version 4.2 of Servoy. The maintenance plugin was designed specifically for being used with solution import hooks. Please consult the its API documentation for specific details about available functions.

...

Code Block
JavaScript
JavaScript
function onBeforeImportSolutionOpen()
{
	application.output("Notifying and disconnecting connected clients...");
	plugins.maintenance.sendMessageToAllClients("A solution upgrade will take place on the server. You will be disconnected in 2 minutes.");
	application.sleep(2 * 60 * 1000);
	plugins.maintenance.sendMessageToAllClients("A solution upgrade will take place on the server. You will be disconnected NOW.");
	plugins.maintenance.shutDownAllClients();
	application.output("Putting server into maintenance mode...");
	plugins.maintenance.setMaintenanceMode(true);
	application.output("Proceeding to import...");
}

The function sends a notification to all connected clients, telling them that in two minutes (or any other amount of time that should be enough for clients to save any important data) they will be disconnected. Then the function waits for two minutes, then it sends another message to the clients telling them that they will be immediately disconnected. Then all connected clients are killed and then the Server is put into maintenance mode. From this moment on no new client will be able to connect to the Server.

The post-import hook module can have the following function as its onOpen event handler:

Code Block
JavaScript
JavaScript
function onAfterImportSolutionOpen()
{
	application.output("Taking server out of maintenance mode.");
	plugins.maintenance.setMaintenanceMode(false);
	application.output("Clients can now connect to the server.");
}

This function takes the Server out of maintenance mode, so that clients can again connect to it.