ServiceControl Error instances are deployed using the particular/ image.
The following minimal example uses docker run to host an Error instance on AWS, with Amazon SQS as the transport, Amazon Aurora PostgreSQL for PostgreSQL storage, and Amazon S3 for message bodies:
docker run -d --name error -p 33333:33333 \
-e AWS_REGION=us-east-1 \
-e TRANSPORTTYPE=AmazonSQS \
-e CONNECTIONSTRING="Region=us-east-1" \
-e STORAGETYPE=PostgreSQL \
-e DATABASE_CONNECTIONSTRING="Host=my-cluster.cluster-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com;Database=ServiceControl;Username=servicecontrol;Token Authentication=AwsRdsIam;SSL Mode=Require" \
-e MESSAGEBODY_STORAGETYPE=S3 \
-e MESSAGEBODY_S3_BUCKETNAME=my-servicecontrol-bodies \
-e REMOTEINSTANCES='[{"api_uri":"http://audit:44444/api"}]' \
-e ENABLEINTEGRATEDSERVICEPULSE="true" \
particular/servicecontrol:latest
The example contains no AWS keys or database password. SQS, S3, and the IAM database login use the AWS SDK default credential chain, such as an IAM role attached to the host or task, and the region set in AWS_REGION.
This example shows one combination of transport, storage, and message body store. Required settings lists the variables for each storage type.
For examples of Particular Service Platform containers used together, including Docker Compose and Kubernetes using a Helm chart, see the Platform Container Examples repository.
Initial setup
Before running the container image normally, it must run in setup mode to create the required message queues and perform upgrade tasks.
The container image will run in setup mode by adding the --setup argument. For example:
# Using docker run
docker run --rm {OPTIONS} {IMAGE} --setup
Setup mode may require different settings, such as a different transport connection string with permissions to create queues.
After setup is complete, the container will exit, and the --rm (or equivalent) option can be used to automatically remove it.
The setup process should be repeated any time the container is updated to a new version.
Simplified setup
Instead of running --setup as a separate container, the setup and run operations can be combined using the --setup-and-run argument:
# Using docker run
docker run {OPTIONS} {IMAGE} --setup-and-run
The --setup-and-run argument runs the setup process when the container starts, after which the application runs normally. This simplifies deployment by removing the need for a separate init container in environments where the setup process does not need different settings.
Using --setup-and-run removes the need to repeat a setup process when the container is updated to a new version.
Do not use --setup or --setup-and-run with an ingestion-only worker. Only the Error instance runs setup.
Skipping queue creation
If the message queues already exist, or the setup process does not have permission to create them, add the --skip-queue-creation argument alongside --setup or --setup-and-run. Only queue creation is skipped; the rest of the setup process still runs. See ServiceControl queues for details on creating queues manually.
# Using docker run
docker run --rm {OPTIONS} particular/servicecontrol --setup --skip-queue-creation
Required settings
The following environment settings are required to run a ServiceControl error instance.
Transport type
Environment variable: TRANSPORTTYPE
Determines the message transport used to communicate with message endpoints. See ServiceControl transport configuration for valid TransportType values.
Transport connection string
Environment variable: CONNECTIONSTRING
Provides the connection information to connect to the chosen transport. The form of this connection string is different for every message transport. See ServiceControl transport support for more details on options available to each message transport.
Storage selection
Added in version 7.0.0
Environment variable: STORAGETYPE
Selects the storage for the instance. This setting is required and has no default. Each storage type needs the variables listed in its own section. Use the same storage variables during setup and normal operation.
| Storage | STORAGETYPE value | Variables |
|---|---|---|
| SQL Server | SQLServer | SQL Server storage |
| PostgreSQL | PostgreSQL | PostgreSQL storage |
| RavenDB | RavenDB | RavenDB storage |
SQL Server storage
Added in version 7.0.0
Environment variables: STORAGETYPE, DATABASE_CONNECTIONSTRING
-e STORAGETYPE=SQLServer \
-e DATABASE_CONNECTIONSTRING="Server=my-server;Database=my-database;User ID=...;Password=...;Encrypt=True" \
The database must exist before setup runs. See SQL Server storage for how to prepare the database, the permissions it needs, and the authentication options. Also set the message body storage variables.
PostgreSQL storage
Added in version 7.0.0
Environment variables: STORAGETYPE, DATABASE_CONNECTIONSTRING
-e STORAGETYPE=PostgreSQL \
-e DATABASE_CONNECTIONSTRING="Host=my-server;Database=my-database;Username=...;Password=..." \
The database must exist before setup runs. See PostgreSQL storage for how to prepare the database, the permissions it needs, and the authentication options. Also set the message body storage variables.
RavenDB storage
Environment variables: STORAGETYPE, RAVENDB_CONNECTIONSTRING
-e STORAGETYPE=RavenDB \
-e RAVENDB_CONNECTIONSTRING="http://servicecontrol-db:8080" \
Set RAVENDB_CONNECTIONSTRING to the URL of the RavenDB database container that stores the instance's data. In production, the database container should be exclusive to the instance and not shared by other ServiceControl instances. See RavenDB container setup. RavenDB storage does not use the message body storage variables.
Versions before 7 support only RavenDB storage and do not have the STORAGETYPE setting. Leave it out and set only RAVENDB_CONNECTIONSTRING.
Message body storage
Added in version 7.0.0
Environment variable: MESSAGEBODY_STORAGETYPE
SQL Server and PostgreSQL storage keep large and binary message bodies in an external message body store. An Error instance using those storage types does not start without this setting, and an Audit instance starts but does not store large or binary bodies. The setting selects the store:
| Store | MESSAGEBODY_STORAGETYPE value | Required variables | Configuration |
|---|---|---|---|
| File system | FileSystem | MESSAGEBODY_FILESYSTEM_STORAGEPATH, with a volume mounted at that path | File system storage |
| Azure Blob Storage | AzureBlob | MESSAGEBODY_AZURE_CONNECTIONSTRING or MESSAGEBODY_AZURE_SERVICEURI | Azure Blob Storage |
| Amazon S3 | S3 | MESSAGEBODY_S3_BUCKETNAME | Amazon S3 |
Give each instance its own directory, container, or key prefix, unless the instances share a database; see sharing a message body store.
Remote instances
Environment variable: REMOTEINSTANCES
A JSON structure that provides URLs for the Error instance to access any remote audit instances. When requesting audit data via the ServiceControl API, the Error instance will communicate with each remote audit instance in a scatter-gather pattern, then return the combined results. The URLs must be accessible directly by the Error instance, not constructed to be accessible from an external browser.
Enable integrated ServicePulse
Environment variable: ENABLEINTEGRATEDSERVICEPULSE
A boolean value specifying whether to enable the integrated ServicePulse for this Error instance.
License
Environment variable: PARTICULARSOFTWARE_LICENSE
The Particular Software license, which is most easily provided to a container as an environment variable. The environment variable should contain the full multi-line contents of the license file.
A license file can also be volume-mounted to the container in the machine-wide license location for Linux:
-v license.xml:/usr/share/ParticularSoftware/license.xml
Ports
33333 is the canonical port exposed by the error instance API within the container, though this port can be mapped to any desired external port.
Health checks
The container image has a health check that calls /. This endpoint allows anonymous requests, also when authentication is enabled. It reports if the process is running.
/ also reports if the instance ingests failed messages.
Use these endpoints for health probes: / for liveness probes, and / for readiness probes and load balancers. Do not restart the container because / fails. A health probe only checks if the instance is available. Do not use other API endpoints for health probes: the API is for ServicePulse only, and the other endpoints require a valid token when authentication is enabled.
Both endpoints are available from version 6.20.
Volumes
The Error instance container keeps no data of its own. Whether it needs a mounted volume depends on the storage type:
- SQL Server or PostgreSQL storage with file system message body storage: mount a durable volume at the path set by
SERVICECONTROL_MESSAGEBODY_FILESYSTEM_STORAGEPATH. Do not share the volume path with another instance. The exception is ingestion-only workers, which mount the same volume as their Error instance. See the file system message body storage guide. - SQL Server or PostgreSQL storage with Azure Blob Storage or Amazon S3: no volume is needed. The data is in the database and in the message body store.
- RavenDB storage: no volume is needed for the data, which is in the RavenDB database. To connect to RavenDB with a client certificate stored in a file, mount the file and point
RAVENDB_CLIENTCERTIFICATEPATHto it. A certificate supplied as a Base64-encoded environment variable needs no volume. See RavenDB client certificate.
The container runs as a non-root user with UID 1654, which must be able to write to the body storage volume. Setup succeeds even when the directory is not writable, and the instance then fails to start up. Give the volume suitable ownership or permissions before starting the instance.
Additional settings
Additional optional settings are documented in Error Instance Configuration Settings, which describes all available settings, allowed values, and the environment variable keys used to configure the container.
When using tools such as Docker Compose that share environment information across many containers, the SERVICECONTROL_ prefix can be dropped from an environment variable name, and the value will still be understood by the container. This facilitates sharing values such as TRANSPORTTYPE when all instances will be configured with the same values.
In the event of a naming collision, a fully qualified key such as SERVICECONTROL_TRANSPORTTYPE will be preferred over the shared TRANSPORTTYPE variant.
Not all settings are relevant to instances running in a container. For example, HTTP hostname and port use standard values inside the container, and are mapped to real hosts and ports by infrastructure external to the container. Be sure to carefully review the documentation for each configuration setting to ensure it is relevant in a container context.
Upgrading
An instance is upgraded by removing the container for the old version and replacing it with a container built using the new version. However, the container must be run in setup mode each time it is upgraded before running it to ingest messages. For example:
docker stop {CONTAINER_NAME}
docker rm {CONTAINER_NAME}
docker pull {IMAGE}:latest
docker run --rm {OPTIONS} {IMAGE}:latest --setup
docker run -d {OPTIONS} {IMAGE}:latest
Note that Docker can cache the latest tag as well as the major/minor tags (such as 5 or 5.) unless the tag is pulled again. To be certain, use the full version tag.