# Standalone

## Standalone application

Standalone backend does not use any special execution environment to execute client jobs. Clients are spawned as local processes so the master and all workers are running as local processes on the same host. The execution host must be a UNIX wokstation because this is the only supported platform for this backend yet.

### Name of the standalone backend

The name of this backend is:

local

This name must be used to identify the backend when using the library to build application.

### Execution of clients

Call of `DC_submitWU()` in master process spawns a new UNIX process using `fork`/`exec` mechanism and starts the executable of the client. Client changes its directory to its own working directory which is prepared by the master for it.

Event handling procedures of the master process (`DC_waitWUEvent()`, `DC_processMasterEvents()`, etc.) check the operating system for the client's process and report it as finished when it disapears.

### Message passing

It is possible to send messages between the master and a client (see `DC_sendMessage()` and `DC_sendResult()` functions). Messages are passed as files. Message files are placed in "message boxes", which are directories created in client's working directory. Name of the message box directories can be specified by configuration options (see ClientMessageBox, and MasterMessageBox), so they will not interfere with client's own created files and directories.

This backend maintains order of the messages so they will be received in the same order as they were sent.

## Configuration options

InstanceUUID

  REQUIRED. Identification of running instance of the application. For Standalone backend it can be any string not just an UUID.

WorkingDirectory

  REQUIRED. Name of working directory of the application. All files that are generated by the application or the DC-API library are placed under this directory. Different applications can use the same working directory because every instance has its own subdirectory there.

ClientMessageBox

  Name of the directory in workunit's working directory where messages are placed which are sent by the client to the master by `DC_sendMessage()`. Default value is `_dcapi_client_messages`.

MasterMessageBox

  Name of the directory in workunit's working directory where `DC_sendWUMessage()` places messages sent by the master to the client. Default value is `_dcapi_master_messages`.

SubresultBox

  Name of the directory in workunit's working directory where `DC_sendResult()` places subresults generated by the client. Default value is `_dcapi_client_subresults`.

Executable

  Name of the executable file of the client (workunit). By default it is the clientName parameter which was passed to `DC_createWU()`.

LeaveFiles

  Specifies if files, directories generated in workunit's working directory should be deleted or not after workunit ends. Zero value means delete and non-zero value means not to delete. Default value is 0.