Rust uses environment variables for a number of configuration options. Some of these include:
variable value description
RUST_LOG debug , info , warn , error minimum Rust error logging level
RUST_TEST_THREADS 1 maximum 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.
The following configuration options are available.
Env Var Default Value Description
SYNC_HOST127.0.0.1 Host address to bind the server to
SYNC_PORT8000 Server port to bind to
SYNC_MASTER_SECRETNone, required Secret used to derive auth secrets
SYNC_ENVIRONMENTdev Environment name (“dev”, “stage”, “prod”)
SYNC_HUMAN_LOGSfalse Enable human-readable logs
SYNC_ACTIX_KEEP_ALIVENone HTTP keep-alive header value in seconds
SYNC_WORKER_MAX_BLOCKING_THREADS512 The maximum number of blocking threads in the worker threadpool. This threadpool is used by Actix-web to handle blocking operations.
Env Var Default Value Description
SYNC_CORS_ALLOWED_ORIGIN* Allowed origins for CORS requests
SYNC_CORS_MAX_AGE1728000 CORS preflight cache seconds (20 days)
SYNC_CORS_ALLOWED_METHODS[“DELETE”, “GET”, “POST”, “PUT”] Allowed methods
Env Var Default Value Description
SYNC_SYNCSTORAGE__DATABASE_URLmysql://root@127.0.0.1/syncstorage Database connection URL
SYNC_SYNCSTORAGE__DATABASE_POOL_MAX_SIZE10 Max database connections
SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_TIMEOUT30 Pool timeout in seconds
SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_LIFESPANNone Max connection age in seconds
SYNC_SYNCSTORAGE__DATABASE_POOL_CONNECTION_MAX_IDLENone Max idle time in seconds
SYNC_SYNCSTORAGE__DATABASE_POOL_SWEEPER_TASK_INTERVAL30 How often, in seconds, a background task runs to evict idle database connections (Spanner only)
SYNC_SYNCSTORAGE__DATABASE_SPANNER_ROUTE_TO_LEADERfalse Send leader-aware headers to Spanner
SYNC_SYNCSTORAGE__SPANNER_EMULATOR_HOSTNone Spanner emulator host (e.g., localhost:9010)
Env Var Default Value Description
SYNC_SYNCSTORAGE__LIMITS__MAX_POST_BYTES2,621,440 Max BSO payload size per request
SYNC_SYNCSTORAGE__LIMITS__MAX_POST_RECORDS100 Max BSO count per request
SYNC_SYNCSTORAGE__LIMITS__MAX_RECORD_PAYLOAD_BYTES2,621,440 Max individual BSO payload size
SYNC_SYNCSTORAGE__LIMITS__MAX_REQUEST_BYTES2,625,536 Max Content-Length for requests
SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_BYTES262,144,000 Max BSO payload size per batch
SYNC_SYNCSTORAGE__LIMITS__MAX_TOTAL_RECORDS10,000 Max BSO count per batch
SYNC_SYNCSTORAGE__LIMITS__MAX_QUOTA_LIMIT2,147,483,648 Max storage quota per user (2 GB)
Env Var Default Value Description
SYNC_SYNCSTORAGE__ENABLEDtrue Enable syncstorage service
SYNC_SYNCSTORAGE__ENABLE_QUOTAfalse Enable quota tracking (Spanner only)
SYNC_SYNCSTORAGE__ENFORCE_QUOTAfalse Enforce quota limits (Spanner only)
SYNC_SYNCSTORAGE__GLEAN_ENABLEDtrue Enable Glean telemetry
SYNC_SYNCSTORAGE__STATSD_LABELsyncstorage StatsD metrics label prefix
Env Var Default Value Description
SYNC_TOKENSERVER__DATABASE_URLmysql://root@127.0.0.1/tokenserver Tokenserver database URL
SYNC_TOKENSERVER__DATABASE_POOL_MAX_SIZE10 Max tokenserver DB connections
SYNC_TOKENSERVER__DATABASE_POOL_CONNECTION_TIMEOUT30 Pool timeout in seconds
Env Var Default Value Description
SYNC_TOKENSERVER__ENABLEDfalse Enable tokenserver service
SYNC_TOKENSERVER__RUN_MIGRATIONSfalse Run DB migrations on startup
SYNC_TOKENSERVER__TOKEN_DURATION3600 Token TTL (1 hour)
Env Var Default Value Description
SYNC_TOKENSERVER__FXA_EMAIL_DOMAINapi-accounts.stage.mozaws.net FxA email domain
SYNC_TOKENSERVER__FXA_OAUTH_SERVER_URLhttps://oauth.stage.mozaws.net FxA OAuth server URL
SYNC_TOKENSERVER__FXA_OAUTH_REQUEST_TIMEOUT10 OAuth request timeout in seconds
SYNC_TOKENSERVER__FXA_METRICS_HASH_SECRETsecret Secret for hashing metrics to maintain anonymity
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__KTYNone Primary JWK key type (e.g., “RSA”)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__ALGNone Primary JWK algorithm (e.g., “RS256”)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__KIDNone Primary JWK key ID
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__FXA_CREATED_ATNone Primary JWK creation timestamp
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__USENone Primary JWK use (e.g., “sig”)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__NNone Primary JWK modulus (RSA public key component)
SYNC_TOKENSERVER__FXA_OAUTH_PRIMARY_JWK__ENone Primary JWK exponent (RSA public key component)
SYNC_TOKENSERVER__FXA_OAUTH_SECONDARY_JWK__*None Secondary JWK (same structure as primary)
Env Var Default Value Description
SYNC_STATSD_HOSTlocalhost StatsD server hostname
SYNC_STATSD_PORT8125 StatsD server port
SYNC_INCLUDE_HOSTNAME_TAGfalse Include hostname in metrics tags