Skip to main content

Configuration

Every Node.js setting can come from the environment or the Synapsys options object. Explicit options win. Environment variables are usually the cleanest way to reuse the same application build in local, test, staging, and production systems.

SYNAPSYS_CORE_URL=https://core.example.com
SYNAPSYS_CORE_TOKEN=syn_replace_with_your_token
SYNAPSYS_WORKER_NAME=billing-api
SYNAPSYS_HEARTBEAT_INTERVAL=5s
SYNAPSYS_CONNECT_TIMEOUT=2s
SYNAPSYS_REQUEST_TIMEOUT=5s
SYNAPSYS_SHUTDOWN_TIMEOUT=10s
SYNAPSYS_FAIL_FAST=false
SYNAPSYS_CAPTURE_CONSOLE=true
SYNAPSYS_LOG_LEVEL=info

Do not commit the file containing the real token. If you use a local .env loader, load it before constructing Synapsys; the SDK does not read .env files itself.

Settings​

OptionEnvironment variableDefaultDescription
enabledSYNAPSYS_ENABLEDtruefalse disables network activity and console capture.
coreUrlSYNAPSYS_CORE_URLnoneRequired Core base URL.
coreTokenSYNAPSYS_CORE_TOKENnoneWorker bearer token.
workerNameSYNAPSYS_WORKER_NAMEnoneRequired stable identity across restarts.
hostSYNAPSYS_HOSTmachine hostnameHost label reported to Core.
heartbeatIntervalSYNAPSYS_HEARTBEAT_INTERVAL5sPositive whole seconds between heartbeats.
failFastSYNAPSYS_FAIL_FASTfalseReject start() if Core is unavailable at startup.
connectTimeoutSYNAPSYS_CONNECT_TIMEOUT2sConnection timeout.
requestTimeoutSYNAPSYS_REQUEST_TIMEOUT5sWhole heartbeat timeout.
shutdownTimeoutSYNAPSYS_SHUTDOWN_TIMEOUT10sHard budget for cooperative process stop and the final heartbeat.
captureConsoleSYNAPSYS_CAPTURE_CONSOLEtrueStream process stdout/stderr to Core.
logLevelSYNAPSYS_LOG_LEVELinfodebug, info, warn, error, or silent.
loggernonebuilt-inA pino-, winston-, bunyan-, or console-compatible logger.

Durations should carry a unit: 250ms, 5s, 2m, or 1h. A number means milliseconds. A unitless string is rejected. Unknown options also throw immediately, which makes misspellings visible during startup.

Options object​

const synapsys = new Synapsys({
workerName: 'billing-api',
heartbeatInterval: '10s',
captureConsole: true,
logger: applicationLogger,
});

Graceful shutdown​

The SDK does not install signal handlers because doing so would change your application's existing shutdown behaviour. Add it to the path you already own:

process.on('SIGTERM', async () => {
await synapsys.stop();
server.close();
});

stop() is idempotent and non-throwing. It stops normal heartbeats, asks all running processes to stop, waits only within shutdownTimeout, sends one final best-effort heartbeat whose commands are ignored, then restores console streams and releases SDK-owned sockets. Pass a one-call override with stop({ timeout: '30s' }). A body that ignores cancellation is named, left alive, and prevented from overlapping a replacement run.

Test and local profiles​

Set SYNAPSYS_ENABLED=false when a run should have no timer, network call, or stream interception. Core configuration is not required while disabled.

Next: define processes and understand cancellation and capture.