The API Server and it's workers are supplied with a default configuration. This can be managed from iCM.
Viewing the Current Configuration
You can view server and worker configuration from the API Server Console. The values you see are a combination of the server and worker default configuration (found in the worker.conf of each worker and the APIServer.conf file) plus the configuration sent to the API Server from iCM.
API Server configuration is visible in the "Settings" tab of the console menu.
To see the configuration of a worker, select it form the "Overview" page of the console, then press the cog icon next to the worker name. Here's the full configuration for a typical Ajax Library worker.
Environment Configuration
When you send configuration to the API Server from iCM, as well as the custom configuration for workers and the server described below, iCM also sends environment configuration.
If you make changes to autoconfig or the iCM Settings section (in particular website user profile mappings) you'll need to resend the API Server configuration from iCM so these changes are propagated throughout your platform.
Custom Configuration
API Server configuration files are held in the iCM custom folder, accessed using the File Manager.
Workers
The "workers" array in the configuration file sets up each worker that should be started, the number of instances of it, and the threads per instance of threaded workers. You can override the value of any property in a worker's default configuration by including it in this file. For example:
{
"name": "ajaxlibrary",
"instances": 4,
"displayName": "new name"
}
Which would make the Ajax Library appear like this in the console:
Not a very practical example! More useful is the "version" property. By default the API Server will use the latest installed version of a worker. You can roll back to an earlier version by explicitly setting the version to start, for example
Additional options for each worker, like the providers used by the Authentication worker or the service the Postcode worker should connect to, are also set here. The documentation for each worker looks at these options in more detail.
API Server
In exceptional circumstances you may need to modify the configuration of the API Server itself. This is done in exactly the same way as workers, adding the properties you'd like to set at the top level of the file, like this:
{
"workerKillTimeout": 6000,
"enableHttp": true,
"workers": [{...}, {...}]
}
The full configuration structure is described below.
Time intervals can either be expressed as integers representing milliseconds, or as objects with time and value properties. For example, one minute could be set as
"cacheSweepInterval": 60000
or
"cacheSweepInterval": { "T":"time", "V":"00:01:00" }
Where "V" represents hours, minutes and seconds. This is useful for longer intervals, like the lifetime of files in the tmp directory, which defaults to
Property | Type | Description |
---|---|---|
tmpPath | String | The path to the tmp directory. Default: "${APISERVER}/tmp" |
staticFileServerRoots | Array | An array of objects, each defining a root directory. The children of these directories will be served by node as static files. See the staticFormCacheRootPath in the API Server console for an example |
excludedUpdateItems | Array | Files or directories that have these names will be excluded from the update process. Default: ["log", "tmp", "workers"] |
workerKillTimeout | Integer (milliseconds) | How long the APIServer will wait to SIGKILL a process if it is still alive after the specified amount of time. Default: 5000 |
enableHttp | Boolean | Enable or disable HTTP access. Default: true |
serverPort | Interger (port number) | The HTTP port number. Default: 5706 |
enableHttps | Boolean | Enable or disable HTTPS access. Default: false (note this does not affect proxied access to the console through iCM or access to publicly available workers like the AJAX library which are rooted through the site frameworks. Both of these will use HTTPS if enabled in those environments) |
httpsPort | Integer (port number) | Only relevant if HTTPS is enabled. Default: 5707 |
httpsCertificate | String | Required if enableHttps is true. Path to a .cer file, relative to the API server data directory. Default: null |
httpsKey | String | Required if enableHttps is true. Path to a .pkcs8 file, relative to the API server data directory. Default: null |
httpsCa | String | An optional path to a file containing CA certificates to trust. If not supplied the Mozilla CA Certificate Store is used |
host | String | Interface to listen on (0.0.0.0 indicates all interfaces). Default: "0.0.0.0" |
localhost | String | The IP address to use for local access to the API Server. (May need to be changed to ::1 on some installations). Default: "127.0.0.1" |
requestTimeout | Integer (milliseconds) | The number of milliseconds of inactivity before a request is forcibly ended at socket level. Default: two minutes |
cacheSweepInterval | Integer (milliseconds) | User data cache sweep interval in milliseconds. Default: one minute |
staleRequestCleanupInterval | Integer (milliseconds) | Stale request cleanup interval for multithreaded workers in milliseconds. Default: one hour |
tmpFileCleanupInterval | Integer (milliseconds) | How often in milliseconds the /tmp cleanup task should run. Default: one hour |
tmpFileLifeTime | Integer (milliseconds) | The maximum lifetime of files in /tmp. Default: five days |
httpLogCleanupInterval | Integer (milliseconds) | How often the http log cleanup task should run. Default: one hour |
httpLogHistorialFilesKept | Integer | Number of historical http logs to keep, excluding the current log file. Default: 5 |
statLogEnabled | Boolean | Whether the stat log should be written to. Default: true |
statLogHistoricalFilesKept | Integer | Number of historical stat logs to keep, excluding the current log file. Default: 5 |
statLogWriteInterval | Integer (milliseconds) | How often to write to the stat log CSV. Default: one minute |
statLogDir | String | The directory to which stat log CSV files are written. Default: "${APISERVER}/log" |
debugWebPort | Integer (port number) | The port that node-inspector binds to. Default: 18080 |
serverLog | Boolean | Whether or not to enable server logging. Default: true |
logPath | String | The path to the log directory. Default: "${APISERVER}/log" |
accessLogFormat | String | The format of the logs. Don't change this |
formidable | Object | Configuration for the formidable node module. The defaults should not be changed{ |
consoleTraceLevel | String | The default worker trace level. Options are "debug", "verbose", "info", "warn" and "error". Can be set to "off" to disable. Default: "info" (this can be changed by a user in the console when turning worker tracing on) |
fileTraceLevel | String | As above |
logName | String | The name prepended to the log files. Default: "apiserver" |
logPath | String | Default: "${APISERVER}/log" |
maxLogFileSize | Integer | The maximum size of each the log file in bytes. Default: 1000000 |
maxLogFiles | Integer | The number of log files to keep. Default: 10 |
enablePasswordRedaction | Boolean | Certain requests (the Gatekeeper for example) include usernames and passwords at some trace levels. Setting this property as true replaces any passwords with the value "[REDACTED]". You may want to disable this in some troubleshooting situations. Default: true |
monitor | Object | The API Server's monitor for heavy load and long running requests. See API Server Console. We don't recommend changing the defaults |
excludePathsFromHttpLog | Object | Each of the paths in this object will be excluded from the HTTP log. This is to prevent the log filling up with background noise (for example web/ajax is called every two seconds). Default: {"^\/web\/.*": "i"} |
traceAllRequests | Boolean | If enabled, traces all calls and responses to the API Server at debug level, regardless of the status of any other settings. This will result in a lot of logging building up very quickly. Default: false |
workerRequestTracingMasterSwitch | Boolean | This setting makes no difference to the temporary tracing enabled in the console. It can be used to globally turn tracing on or off for any worker that has traceWorkerRequests set as true (which will be none unless you've set that up in your worker config). Default: true |
traceWorkerRequests | Boolean | Whether to enable tracing for the API Server's "manager worker". This property can also be set at the config level for individual workers and saves you having to turn temporary tracing on and off in the console. Default: false |
temporaryTracingPeriod | Integer (milliseconds) | The duration of temporary tracing when enabled in the console. Default: fifteen minutes |
checkDbConnOnStartup | Boolean | Whether or not to check the API Server can access the default database (eg iCM) before starting the workers. If the query fails the API Server will not start any of its workers. Instead, it will wait for "checkDbConnOnStartupIntervalMs" (see below) and try again on repeat until it connects. This setting guards against situations where a web server may be restarted and the API Server started before the database server is ready. If configuring a 'remote' API Server within a client's DMZ, communicated with over a VPN, this setting will probably need to be false. Default: true |
checkDbConnOnStartupIntervalMs | Integer (milliseconds) | Default: 60000 |
checkDbConnOnStartupConnectionTimeoutMs | Integer (milliseconds) | How long the driver will wait for a database connection. Note: Only respected by the PostgreSQL driver. Default: 5000 |
checkDbConnOnStartupRequestTimeoutMs | Integer (milliseconds) | How long the driver will wait for a response from the SQL query request made to the database server. Default: 5000 |
checkDbConnOnStartupDatasourceNames | Array | An optional array of datasource names to check before starting the API Server. All must be reachable before any workers are started. If null only the default database (usually icm) will be checked. Default: null |
synchroniseWorkerStartup | Boolean | Default false. If true workers will start one at a time. This is significantly slower than the standard start-up but has less impact on CPU |
Datasources
It's also possible to define additional datasources in the API Server configuration, allowing your forms, End Points and workers like the FormUtils Worker to interact with data in external (ie not the iCM) databases.
To do this, add the top level environmentConfig object with the details of your database. The "default" should be left as "icm".
"environmentConfig": {
"dataBases": {
"default": "icm",
"dataSources": {
"mydatabase": {
"databaseDriverClass": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
"databaseUserName": "theusername",
"databaseConnectionString": "jdbc:sqlserver://GI00645:1433;DATABASENAME=mydatabase;sendStringParametersAsUnicode=true;SelectMethod=direct",
"databasePassword": "thepassword"
}
}
}
}