Child pages
  • Maintenance Mode

Versions Compared

Key

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

...

Function

...

isInMaintenanceMode

...

Description

...

Returns true if the server is in maintenance mode, false otherwise.

...

Example

...

No Format
nopaneltrue

if (plugins.maintenance.isInMaintenanceMode())
	application.output("Server is in maintenance mode.");
else
	application.output("Server is not in maintenance mode.");

...

Function

...

setMaintenanceMode

...

Description

...

Example

...

No Format
nopaneltrue

plugins.maintenance.setMaintenanceMode(!plugins.maintenance.isInMaintenanceMode());

...

Function

...

getConnectedClients

...

Description

...

Returns an array of IClientInformation elements describing the clients connected to the server.

...

Example

...

No Format
nopaneltrue

var clients = plugins.maintenance.getConnectedClients();
application.output("There are " + clients.length + " connected clients.");
for (var i = 0; i < clients.length; i++)
	application.output("Client has clientId '" + clients[i].getClientId() + "' and has connected from host '" + clients[i].getHostAddress() + "'.");

...

Function

...

sendMessageToAllClients

...

Description

...

Example

...

No Format
nopaneltrue

plugins.maintenance.sendMessageToAllClients("Hello, all clients!");

...

Function

...

sendMessageToClient

...

Description

...

Example

...

No Format
nopaneltrue

var clients = plugins.maintenance.getConnectedClients();
for (var i=0; i<clients.length; i++)
	plugins.maintenance.sendMessageToClient(clients[i].getClientId(), "Hello, client " + clients[i].getClientId() + "!");

...

Function

...

shutDownAllClients

...

Description

...

Shuts down all connected clients.

...

Example

...

No Format
nopaneltrue

plugins.maintenance.shutDownAllClients();

...

Function

...

shutDownClient

...

Description

...

Example

...

No Format
nopaneltrue

var clients = plugins.maintenance.getConnectedClients();
for (var i=0; i<clients.length; i++)
	plugins.maintenance.shutDownClient(clients[i].getClientId());

...

Function

...

getServer

...

Description

...

Example

...

No Format
nopaneltrue

var server = plugins.maintenance.getServer("example_data");
if (server) {
	var tableNames = server.getTableNames();
	application.output("There are " + tableNames.length + " tables.");
	for (var i=0; i<tableNames.length; i++)
		application.output("Table " + i + ": " + tableNames[i]);
	}
else {
	plugins.dialogs.showInfoDialog("Attention","Server 'example_data' cannot be found.","OK");
}

...

Function

...

getServerNames

...

Description

...

Example

...

nopaneltrue

...

Advanced Features Related to Solution Import from Servoy Admin Page

During solution import from the Servoy Admin Page, modules with certain name patterns are handled in a special way. Modules whose names start with "before_import" are handled as pre-import hooks. Their onOpen event handlers are executed before the solution is actually imported. Similarly, modules whose names start with "after_import" are handled as post-import hooks. Their onOpen event handles are executed after the solution is actually imported.

If you have several modules that start with "before_import" or "after_import", they will be all handled in this way, but no handling order is guaranteed. It is recommended that you have at most one pre-import and at most one post-import hook in your exported solutions.

While the onOpen event handlers of pre-import and post-import hooks are being executed, any output printed with application.output will be redirected to the import log, which you can see in the Servoy Admin Page.

A simple example

Suppose you have a solution called "import_sample_01", with two modules called "before_import_01" and "after_import_01". The "before_import_01" module has the following onOpen event handler:

Code Block
JavaScript
JavaScript

function onBeforeImportSolutionOpen()
{
	application.output("Method executed before solution import.");
}

The "after_import_01" module has the following onOpen event handler:

Code Block
JavaScript
JavaScript

function onAfterImportSolutionOpen()
{
	application.output("Method executed after solution import.");
}

If you export this solution together with its two modules, and then you import it throught the Servoy Admin Page, in the import log you should see the lines

No Format

[info]	Executing pre-import hook module 'before_import_01'.
[info]	Method executed before solution import.

before any message related to the actual solution import, and also you should see the lines

No Format

[info]	Executing post-import hook module 'after_import_01'.
[info]	Method executed after solution import.

after all messages related to the actual solution import.

What else can you do? The maintenance plugin.

The pre-import and post-import hooks were introduced for allowing you to automatically perform administrative tasks on the server while importing solutions:

  • Send messages to connected clients, or even kill connected clients.
  • Put the server into maintenance mode for the duration of the solution import.
  • Perform operations on databases.

These operations can be performed through the maintenance plugin, which is available since version 4.2 of Servoy. Since the maintenance plugin was designed specifically for being used with solution import hooks, please consult its documentation for more details. There you will also find several examples of solution import hooks.