WorkerService

MacroModule

genre

Remote

author

MeVis Medical Solutions AG

package

MeVisLab/Standard

definition

WorkerService.def

Purpose

This module configures a Worker service for MeVisLab. A Worker service can be used in two different scenarios:

For use with remote modules from a MeVisLab instance. A MeVisLab instance can create remote modules on a remote host by using scripting and access this module through a proxy module locally.

For use with a web client. For this purpose the Worker service also acts as a HTTP server (though this is not absolutely necessary, since any HTTP server will do).

See also the Remote Modules overview for the configuration details.

Usage

The Worker service can serve different configurations of MeVisLab installations.

Settings are updated/added by invoking a MeVisLab in the desired configuration and using this module to add/update the configuration in the list displayed on the left. This will then record some crucial environment variables and the executable path of the running MeVisLab process. This will be used to start an (mostly) identical MeVisLab process from the Worker service.

The selected configuration can be modified in the “Selected Configuration” box.

You can install, uninstall, start and stop the Worker service directly from this module, but note that you need administrator rights for this. Also note the special considerations for Windows Vista and Windows 7 under “Tips”.

Details

The “Save” button will save all configurations to a XML file at a location where it will be found by the Worker service. Look in the “Debug Output” View of MeVisLab to see where exactly the file resides.

The XML file has different sections for each written configuration. These can have the following relevant configuration keys:

connectionType, modulePort, httpServerPort, executablePath, executableArguments, overrideLicensePath, ignorePrefs, preferencesPath, maxLogFileSize, logFileName, writeMeVisLabLogFiles, debugMode, maxNumberConnections, gpuCount, sslConfigFile, applicationConfigDir, environment

The configuration key environment in turn contains other keys that will be set as environment variables when starting a worker process.

All values can be modified from the module panel.

Tips

You probably should not install the Worker service as a service under Windows Vista and later Windows versions, since services don’t have access to the graphics card under these operating systems and fall back to the OpenGL software emulation, which means that e.g. remote rendering of viewers will fail. This is ok if you do not plan to use remote rendering or OpenGL, otherwise you need to call MeVisLab\IDE\bin\MeVisLabWorkerService.exe -exec from a user account.

Another point to consider when installing under Windows is the firewall. You need to configure the firewall to allow the configured ports for the Worker service.

If you afterwards still have problems to reach the service from a web client, have a look at the proxy settings of the browser. Older proxies probably will block the WebSocket connection, so a proxy should not be used for these connections.

Windows

Default Panel

../../../Modules/Macros/Workers/mhelp/Images/Screenshots/WorkerService._default.png

Parameter Fields

Field Index

Add: Trigger

Heartbeat Timeout: Integer

Process Decay Timeout: Integer

Alive Check Port: Integer

Http Server Port: Integer

Remove: Trigger

Application Config Dir: String

Ignore user preferences file: Bool

Save: Trigger

Application Started Url: String

Install: Trigger

Serve application files: Bool

Application Stopped Url: String

IP range to allows using Control URLs:: String

Set Binary Message Timeout: Bool

Authentication Request Url: String

IP range to serve Info URLs to:: String

Set Heartbeat Timeout: Bool

Authorization for connection to Control URLs: String

Load: Trigger

Set Process Decay Timeout: Bool

Authorization for connection to Info URLs: String

Log File Name: String

Set Websocket Message Timeout:: Bool

Binary Message Timeout: Integer

Max Log File Size: Integer

settingsChanged: Trigger

Compiler Version: String

Max Number Connections: Integer

Ssl Config File: String

Connection Type: Enum

Max Number Pending Connection Requests: Integer

Start (runService): Trigger

currentIndex: Integer

Mime Type: String

Start (startProcess): Trigger

Debug mode: Bool

MLAB_ROOT: String

Status: String

Disable console forwarding: Bool

modified: Bool

Stop (stopService): Trigger

Disallow Binary Messages: Bool

Module Port: Integer

Stop (stopProcess): Trigger

Executable Arguments: String

Only accept local connections: Bool

Uninstall: Trigger

Executable Path: String

Override License Path: String

Update: Trigger

Extra File Types To Serve: String

PATH: String

Websocket Message Timeout: Integer

File Extensions: String

Preferences Path: String

Write worker log files: Bool

Gpu Count: Integer

Prestart Workers: Integer

Visible Fields

Status

name: status, type: String, persistent: no

Result of the last operation.

Save

name: saveSettings, type: Trigger

Save the current configurations. Watch the “Debug Output” view of MeVisLab to see where the file has been saved.

Load

name: loadSettings, type: Trigger

Load the current configurations.

Add

name: addSetting, type: Trigger

Add the configuration of the currently running MeVisLab as a configuration.

You must save the configurations (and restart the service) for this to take effect.

Remove

name: removeSelectedSetting, type: Trigger

Remove the currently selected configuration from the list.

You must save the configurations (and restart the service) for this to take effect.

Update

name: updateSelectedSetting, type: Trigger

Update the selected configuration with the configuration of the currently running MeVisLab. This is disabled when the proxy mode is selected as connection type, since the values to be updated are not used in this mode.

You must save the configurations (and restart the service) for this to take effect.

Install

name: installService, type: Trigger

Install the Worker service as a service if not already done (not supported under Linux).

Uninstall

name: uninstallService, type: Trigger

Uninstall the Worker service if not already done (not supported under Linux).

Start (runService)

name: runService, type: Trigger

Start the Worker service (not supported under Linux).

Stop (stopService)

name: stopService, type: Trigger

Stop the Worker service (not supported under Linux).

Start (startProcess)

name: startProcess, type: Trigger

Warning - will stop previously running process or service

Stop (stopProcess)

name: stopProcess, type: Trigger

Warning - will also stop service if running

Connection Type

name: connectionType, type: Enum, persistent: no

Sets the connection type of the selected configuration.

Values:

Title

Name

Deprecated Name

Description

WebSocket

websocket

WebSocket connections are used by Web clients.

In this mode the connection is directly passed on to the worker process.

Binary

binary

Binary connections are used by MeVisLab itself and usually by native clients (like e.g. C#).

In this mode the connection is directly passed on to the worker process.

Full Proxy

fullProxy

proxy

In the full proxy mode all connections are piped through the service itself.

This allows to have several different applications for the same WebSocket and HTTP port, since the service can have a look at the requests and multiplex them accordingly. The applications themselves are configured through separate configuration files (it is assumed that they are installed separately). The names of the configuration files are taken as the application name. This name must be given in the URI to access the HTML resources (see Http Server Port).

The URI used for the WebSocket connection must like-wise contain the application name, this is automatically done for you by the MeVisLab Web Toolkit.

Single App Proxy

singleAppProxy

In the single application proxy mode all connections are piped through the service itself, but otherwise this behaves more like the pass-on websocket or binary modes.

One distinguishing feature is that one can, unlike in the pass-on websocket or binary modes, define an Authentication Request Url. Also the used connection protocol is determined automatically.

Module Port

name: modulePort, type: Integer, minimum: 0, maximum: 65535, persistent: no

The port under which to reach an MeVisLab worker instance.

Alive Check Port

name: aliveCheckPort, type: Integer, minimum: 0, maximum: 65535, persistent: no

The port on which the worker server listens for alive check connections.

Http Server Port

name: httpServerPort, type: Integer, minimum: 0, maximum: 65535, persistent: no

The port under which to access (by http protocol) files from the MeVisLab installation.

The files from the installation will be accessible under http(s)://hostname:httpServerPort/Packages/PackageGroup/Package/… (in non-proxy mode) or http(s)://hostname:httpServerPort/Applications/myApplicationName/PackageGroup/Package/… (in proxy mode). Only files ending on html, js, css, jpg, tif, gif or png will currently be served.

Special: http(s)://hostname:httpServerPort/Settings/webSocketPort will return a file only containing the port number of the WebSocket port. This is used by the JavaScript code to get at the port for the WebSocket connection.

http(s)://hostname:httpServerPort/Settings/connectionsAllowed will return a file containing “false” if Max Number Connections was set and the connection limit is reached. Otherwise the file will contain “true”.

Executable Path

name: executablePath, type: String, persistent: no

The path to the MeVisLab executable to start for each connection.

In proxy mode this should be specified in the application configuration file instead.

Executable Arguments

name: executableArguments, type: String, persistent: no

Arguments to use when starting MeVisLab - if not given the default is “-quick -noide”

Override License Path

name: overrideLicensePath, type: String, persistent: no

The path to the MeVisLab license to use. If not given the default is used.

Ignore user preferences file

name: ignorePrefs, type: Bool, persistent: no

If set ignore the user’s preferences file in the MeVisLab worker.

Preferences Path

name: preferencesPath, type: String, persistent: no

Set the path to an additional preferences file for the MeVisLab worker.

Max Log File Size

name: maxLogFileSize, type: Integer, minimum: 0, persistent: no

The maximum size for the log file - no log file is generated if the value is 0.

Log File Name

name: logFileName, type: String, persistent: no

The file name of the log file for this worker configuration - if not given, it will be “worker_$(modulePort).log”, relative to the location of the configuration file.

Write worker log files

name: writeMeVisLabLogFiles, type: Bool, persistent: no

If set, each MeVisLab worker instance will automatically write a log file with a customized file name containing the start time and the application name.

Debug mode

name: debugMode, type: Bool, persistent: no

If set, one MeVisLab instance will be started in advance for this configuration (so one can attach a debugger to it) before any connection request is made. Additionally each MeVisLab instance will write a log file.

Disable console forwarding

name: disableConsoleForwarding, type: Bool, persistent: no

Setting this prevents that logging messages from the worker process are sent to the client. In security sensitive applications this should probably be always on, since this could leak information about vulnerabilities of the application.

Only accept local connections

name: onlyAcceptLocalConnections, type: Bool, persistent: no

If set, only connections from the local address (i.e. from the same host) will be accepted

Serve application files

name: serveApplicationFiles, type: Bool, persistent: no

Should application files by served by the http server? If not, one can still configure access to the Info and Control URLS.

Prestart Workers

name: prestartWorkers, type: Integer, minimum: 0, persistent: no

Set the number of worker processes that are pre-started for this configuration. Not available if the connection type is “Full Proxy”.

Max Number Connections

name: maxNumberConnections, type: Integer, minimum: 0, persistent: no

Restricts the number of connections that can be active for a configuration. When this number is reached, any new connection request is rejected. 0 means unlimited connections.

Max Number Pending Connection Requests

name: maxNumberPendingConnectionRequests, type: Integer, minimum: 0, persistent: no

Set the number of connection requests that can be pending, i.e., waiting for a worker to be assigned, until the connection is immediately denied. This value is only used if Max Number Connections is set to unlimited (i.e., it is 0). If this value also is 0, a default value is used.

Gpu Count

name: gpuCount, type: Integer, minimum: 0, persistent: no

Set the number of graphics cards available - new MeVisLab instances will be assigned to graphics cards in a round-robin scheme. This currently only works for NVidia cards.

MLAB_ROOT

name: mlabRoot, type: String, persistent: no

Must point to the directory containing the packages. This is needed for the http server.

PATH

name: path, type: String, persistent: no

This is initialized with the content of the PATH environment variable when the configuration is added/updated.

Compiler Version

name: compilerVersion, type: String, persistent: no

The compiler version of the MeVisLab installation. (This setting might be unnecessary.)

Binary Message Timeout

name: binaryMessageTimeout, type: Integer, minimum: 0, persistent: no

Timeout value in seconds. See Set Binary Message Timeout.

Websocket Message Timeout

name: websocketMessageTimeout, type: Integer, minimum: 0, persistent: no

Timeout value in seconds. See Set Websocket Message Timeout:.

Heartbeat Timeout

name: heartbeatTimeout, type: Integer, minimum: 0, persistent: no

Timeout value in seconds. See Set Heartbeat Timeout.

Process Decay Timeout

name: processDecayTimeout, type: Integer, minimum: 0, persistent: no

Timeout value in seconds. See Set Process Decay Timeout.

IP range to serve Info URLs to:

name: infoUrlsSubnet, type: String, persistent: no

If this is configured, the embedded HTTP server provides run-time information about current connections under the URL http(s)://serverhost:httpPort/Info/.

The format for the subnet specifier is that which is understood by QHostAddress::parseSubnet.

Authorization for connection to Info URLs

name: connectionInfoAuthorization, type: String, persistent: no

If Info URLs are configured, you have to specify additional authorization information (user name and password) to access detailed information about connections (including IP addresses in Proxy mode).

The format of the authorization is username:password.

IP range to allows using Control URLs:

name: controlUrlsSubnet, type: String, persistent: no

If this is configured, the embedded HTTP server allows to manually prestart workers through the URL http(s)://serverhost:httpPort/Control/prestartWorker?application=myapplication. The application name must only be given for the full proxy mode (see Connection Type).

The format for the subnet specifier is that which is understood by QHostAddress::parseSubnet.

Authorization for connection to Control URLs

name: connectionControlAuthorization, type: String, persistent: no

If Controls URLs are configured, you have to specify additional authorization information (user name and password) to access the control interface.

The format of the authorization is username:password.

Ssl Config File

name: sslConfigFile, type: String, persistent: no

Give the path to a config file in XML syntax describing a SSL certicate and a private key to use for connection encryption. If given, both HTTP and WebSocket/MeVisLab accesses will be encrypted.

The config file contains a top-level <ssl> element, which in turn contains a <privateKey> and a <certificate> element which contain the path to the corresponding files. These elements also have the attribute encoding, which can be “pem” or “der”, and the private key has the attribute algorithm, which can be “rsa” or “dsa”.

There is an example for such a file in MeVisLab/IDE/Configuration/Installers/WorkerService/config/exampleSSL.

Application Config Dir

name: applicationConfigDir, type: String, persistent: no

Only used in proxy mode. Contains the path to the directory with the application-specific configuration files.

These configuration files basically contain the same entries as the other connection modes. There is an example for such a file in MeVisLab/IDE/Configuration/Installers/WorkerService/config/applications.

The default value for this is “applications”, which is relative to the location of the WorkerService configuration file.

Authentication Request Url

name: authenticationRequestUrl, type: String, persistent: no

Only used in proxy mode: Contains an URI that will be accessed by the worker service when a WebSocket connection is initiated to determine if this connection is allowed.

The URI request must return OK (code 220), otherwise the WebSocket connection is blocked. The URI can contain the variables $(applicationName) and $(authenticationToken), which are extracted from the WebSocket URI (which follows the name scheme ws(s)://hostname:port/someMagicString/applicationName/authenticationToken).

Application Started Url

name: applicationStartedUrl, type: String, persistent: no

Only used in proxy mode: Contains an URI that will be accessed by the worker service when a WebSocket connection is passed to a MeVisLab worker.

The same variables as for Authentication Request Url are available.

Application Stopped Url

name: applicationStoppedUrl, type: String, persistent: no

Only used in proxy mode: Contains an URI that will be accessed by the worker service when a WebSocket connection to a MeVisLab worker ends.

The same variables as for Authentication Request Url are available.

File Extensions

name: fileExtensions, type: String, persistent: no

The file extensions (without a dot) for a new file type that can be added. Separate multiple extensions by a “;”.

Mime Type

name: mimeType, type: String, persistent: no

The mime type for a new file type that can be added.

Extra File Types To Serve

name: extraFileTypesToServe, type: String, persistent: no

This is the value field for the extra file types to serve list view.

Set Binary Message Timeout

name: useBinaryMessageTimeout, type: Bool, persistent: no

Sets the timeout that closes the connection if no messages have been received for this many seconds. An automatic keep-alive message is sent every 5 seconds. Set this to 0 to disable this (e.g. for debugging).

Set Websocket Message Timeout:

name: useWebsocketMessageTimeout, type: Bool, persistent: no

Same as Set Binary Message Timeout, but for WebSocket connections (e.g. the web client). As the web client usually does not send keep-alive messages, this can be used to disconnect the client after longer periods of inactivity.

Set Heartbeat Timeout

name: useHeartbeatTimeout, type: Bool, persistent: no

Will terminate the worker process when no heartbeat was received from the main thread of the worker for this time. The heartbeat is sent every 5 seconds.

Set Process Decay Timeout

name: useProcessDecayTimeout, type: Bool, persistent: no

Set timeout after which the worker process will be killed if inactive. As inactive counts

  • the time before the newly started worker process announces itself to the WorkerService,

  • the time after the worker process has been told by the WorkerService to terminate itself, and

  • in proxy mode also the time after the connection to the client has been terminated (by either side).

Disallow Binary Messages

name: disallowBinaryMessages, type: Bool, persistent: no

If set, no binary messages will be accepted while text based messages are still being processed. This has to be set in the client as well. See general application argument disableBinaryMessages in MeVisLab Web ToolKit Reference MeVisLab Web Toolkit Reference, section Integration into HTML pages.

Hidden Fields

currentIndex

name: currentIndex, type: Integer, default: -1

Index of the currently selected configuration.

modified

name: modified, type: Bool, persistent: no

This is set when the settings have been changed since loading.

settingsChanged

name: settingsChanged, type: Trigger

This gets touched to update the user interface.