Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Rust uses environment variables for a number of configuration options. Some of these include:

variablevaluedescription
RUST_LOGdebug, info, warn, errorminimum Rust error logging level
RUST_TEST_THREADS1maximum number of concurrent threads for testing.

In addition, Sync server configuration options can either be specified as environment variables (prefixed with SYNC_*) or in a configuration file using the --config option.

For example the following are equivalent:

$ SYNC_HOST=0.0.0.0 SYNC_MASTER_SECRET="SuperSikkr3t" SYNC_SYNCSTORAGE__DATABASE_URL=mysql://scott:tiger@localhost/syncstorage cargo run
$ cat syncstorage.local.toml
host = "0.0.0.0"
master_secret = "SuperSikkr3t"

[syncstorage]
database_url = "mysql://scott:tiger@localhost/syncstorage"
$ cargo run -- --config syncstorage.local.toml

Options can be mixed between environment variables and configuration. Environment variables have higher precedence.

Options

The following configuration options are available.

Server Settings

Env VarDefault ValueDescription
SYNC_HOST127.0.0.1Host address to bind the server to
SYNC_PORT8000Server port to bind to
SYNC_MASTER_SECRETNone, requiredSecret used to derive auth secrets
SYNC_ENVIRONMENTdevEnvironment name (“dev”, “stage”, “prod”)
SYNC_HUMAN_LOGSfalseEnable human-readable logs
SYNC_ACTIX_KEEP_ALIVENoneHTTP keep-alive header value in seconds
SYNC_WORKER_MAX_BLOCKING_THREADS512The maximum number of blocking threads in the worker threadpool. This threadpool is used by Actix-web to handle blocking operations.

CORS

Env VarDefault ValueDescription
SYNC_CORS_ALLOWED_ORIGIN*Allowed origins for CORS requests
SYNC_CORS_MAX_AGE1728000CORS preflight cache seconds (20 days)
SYNC_CORS_ALLOWED_METHODS[“DELETE”, “GET”, “POST”, “PUT”]Allowed methods

Syncstorage Database

Env VarDefault ValueDescription
SYNC_SYNCSTORAGE__DATABASE_URLmysql://root@127.0.0.1/syncstorageDatabase connection URL
SYNC_SYNCSTORAGE__DATABASE_POOL_MAX_SIZE10Max database connections
SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_TIMEOUT30Pool timeout in seconds
SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_LIFESPANNoneMax connection age in seconds
SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_MAX_IDLENoneMax idle time in seconds
SYNC_SYNCSTORAGE__DATABASE_POOL_SWEEPER_TASK_INTERVAL30How often, in seconds, a background task runs to evict idle database connections (Spanner only)
SYNC_SYNCSTORAGE__DATABASE_SPANNER_ROUTE_TO_LEADERfalseSend leader-aware headers to Spanner
SYNC_SYNCSTORAGE__SPANNER_EMULATOR_HOSTNoneSpanner emulator host (e.g., localhost:9010)

Syncstorage Limits

Env VarDefault ValueDescription
SYNC_SYNCSTORAGE__LIMITS__MAX_POST_BYTES2,621,440Max BSO payload size per request
SYNC_SYNCSTORAGE__LIMITS__MAX_POST_RECORDS100Max BSO count per request
SYNC_SYNCSTORAGE__LIMITS__MAX_RECORD_PAYLOAD_BYTES2,621,440Max individual BSO payload size
SYNC_SYNCSTORAGE__LIMITS__MAX_REQUEST_BYTES2,625,536Max Content-Length for requests
SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_BYTES262,144,000Max BSO payload size per batch
SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_RECORDS10,000Max BSO count per batch
SYNC_SYNCSTORAGE__LIMITS__MAX_QUOTA_LIMIT2,147,483,648Max storage quota per user (2 GB)

Syncstorage Features

Env VarDefault ValueDescription
SYNC_SYNCSTORAGE__ENABLEDtrueEnable syncstorage service
SYNC_SYNCSTORAGE__ENABLE_QUOTAfalseEnable quota tracking (Spanner only)
SYNC_SYNCSTORAGE__ENFORCE_QUOTAfalseEnforce quota limits (Spanner only)
SYNC_SYNCSTORAGE__GLEAN_ENABLEDtrueEnable Glean telemetry
SYNC_SYNCSTORAGE__STATSD_LABELsyncstorageStatsD metrics label prefix

Tokenserver Database

Env VarDefault ValueDescription
SYNC_TOKENSERVER__DATABASE_URLmysql://root@127.0.0.1/tokenserverTokenserver database URL
SYNC_TOKENSERVER__DATABASE_POOL_MAX_SIZE10Max tokenserver DB connections
SYNC_TOKENSERVER__DATABASE_POOL_CONNECTION_TIMEOUT30Pool timeout in seconds

Tokenserver Features

Env VarDefault ValueDescription
SYNC_TOKENSERVER__ENABLEDfalseEnable tokenserver service
SYNC_TOKENSERVER__RUN_MIGRATIONSfalseRun DB migrations on startup
SYNC_TOKENSERVER__TOKEN_DURATION3600Token TTL (1 hour)

Tokenserver+FxA Integration

Env VarDefault ValueDescription
SYNC_TOKENSERVER__FXA_EMAIL_DOMAINapi-accounts.stage.mozaws.netFxA email domain
SYNC_TOKENSERVER__FXA_OAUTH_SERVER_URLhttps://oauth.stage.mozaws.netFxA OAuth server URL
SYNC_TOKENSERVER__FXA_OAUTH_REQUEST_TIMEOUT10OAuth request timeout in seconds
SYNC_TOKENSERVER__FXA_METRICS_HASH_SECRETsecretSecret for hashing metrics to maintain anonymity
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__KTYNonePrimary JWK key type (e.g., “RSA”)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__ALGNonePrimary JWK algorithm (e.g., “RS256”)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__KIDNonePrimary JWK key ID
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__FXA_CREATED_ATNonePrimary JWK creation timestamp
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__USENonePrimary JWK use (e.g., “sig”)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__NNonePrimary JWK modulus (RSA public key component)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__ENonePrimary JWK exponent (RSA public key component)
SYNC_TOKENSERVER__FXA_OAUTH_SECONDARY_JWK__*NoneSecondary JWK (same structure as primary)

StatsD Metrics

Env VarDefault ValueDescription
SYNC_STATSD_HOSTlocalhostStatsD server hostname
SYNC_STATSD_PORT8125StatsD server port
SYNC_INCLUDE_HOSTNAME_TAGfalseInclude hostname in metrics tags