GatewayRuntime configuration files are stored under GatewayApp/Configuration/. The runtime loads appsettings.json first, then reads the JSON files in Configuration/. Use these files to adjust service ports, database connections, JWT security, log retention, OAuth2 login, and capacity limits.
| File | Purpose |
|---|
WebApiOptions.json | GatewayRuntime Web/API port and allowed cross-origin sources |
Database.json | Default business database, backend log database, operation log database, and SQL log database connections |
LoggerOptions.json | Process logs, gateway business logs, admin logs, retention policies, and ASP.NET log levels |
JWTOptions.json | Token issuer, expiration time, signing algorithm, token type, and secret |
ChannelThread.json | Channel check interval and channel, device, and variable capacity limits |
IdGeneratorOptions.json | Snowflake ID algorithm, base time, worker ID, and sequence settings |
OAuth2Options.json | OAuth2 login, callback address, default role, and external providers |
SeedDataOptions.json | Whether to force-refresh built-in users, roles, menus, and buttons |
| Directory | Description |
|---|
DB/ | Default business database directory. The default SQLite file is ThingsGateway.db. |
OTHERDB/ | Auxiliary databases for backend logs, operation logs, SQL logs, and related records. |
Configuration/ | Runtime configuration files. |
Logs/ | Runtime log files. The actual path follows the log configuration. |
GatewayApp/ | GatewayRuntime program directory. Do not move or clean files while the runtime is running. |
| Item | Description | Default |
|---|
Port | GatewayRuntime Web/API listening port | 6100 |
CorsOrigins | Allowed cross-origin sources. Empty means all sources are allowed. | Empty |
Restart GatewayRuntime after changing the port. If Watchdog manages the runtime, also check the Gateway API port configured in Watchdog.
| ConfigId | Default Connection | Purpose |
|---|
Default | Data Source=DB/ThingsGateway.db;journal mode=WAL | Business configuration, channels, devices, variables, scripts, nodes, and other core data |
Backend | Data Source=OTHERDB/Backend.db;journal mode=WAL | Backend logs, channel logs, device logs, rule logs, and data forwarding logs |
Operate | Data Source=OTHERDB/Operate.db;journal mode=WAL | Operation logs, RPC logs, and audit records |
SqlLog | Data Source=OTHERDB/SqlLog.db;journal mode=WAL | SQL execution logs |
The default SQLite connections explicitly enable WAL mode. When copying or backing up a running SQLite deployment, also account for possible -wal and -shm files. When switching to another database, confirm the connection string, database type, account permissions, and initialization plan before restarting the runtime.
| Item | Description | Default |
|---|
LoggerOptions.LogLevel | Overall process file log level: Trace, Debug, Info, Warning, Error, or Critical | Info |
LoggerOptions.ConsoleLogLevel | Console log level. Empty follows LogLevel. | Info |
LoggerOptions.LogPath | File log directory. | Logs/XTrace |
LoggerOptions.LogFileMaxMegabytes | Maximum size of a single log file. 0 means unlimited. | 5 |
LoggerOptions.LogFileBackups | Number of retained log files. 0 means unlimited. | 10 |
GatewayLogOptions.*DaysAgo | Retention days for RPC, channel, device, rule engine, and data forwarding logs. | 30 |
GatewayLogOptions.*MaxRowCount | Maximum retained rows for gateway business logs. 0 means unlimited. | 2000000, except rule engine 0 |
AdminLogOptions.*DaysAgo | Retention days for operation, backend, SQL, and audit logs. | 30 |
AdminLogOptions.*MaxRowCount | Maximum retained rows for admin logs. 0 means unlimited. | 2000000 |
| Item | Description |
|---|
Issuer | Token issuer. |
ExpiredTime | Token expiration time in minutes. |
Algorithm | Signing algorithm. |
Type | Token type. |
Secret | Token signing secret. Use an environment variable or a secure site-specific value in production. |
Change the default secret before production use.
| Item | Description |
|---|
CheckInterval | Channel and device status check interval, in milliseconds. |
MaxChannelCount | Maximum allowed channel count. |
MaxDeviceCount | Maximum allowed device count. |
MaxVariableCount | Maximum allowed variable count. |
The actual number of items that can be created is also limited by license and hardware resources.
| Item | Description |
|---|
DefaultRoleId / DefaultRoleCode | Default role used when OAuth2 creates a new user. |
AutoCreateMode | Whether first-time OAuth2 login can create a user automatically. |
FrontendCallbackUrl | Frontend callback address after OAuth2 login. |
CallbackBaseUrl | Backend callback base address. |
Providers | External login providers, such as GitHub. |
The sample configuration contains a GitHub provider for demonstration. In production, create your own provider application and prefer environment variables for ClientId and ClientSecret. If external login is enabled, replace callback addresses according to the site network and HTTPS configuration.
| Item | Description |
|---|
Method | Snowflake algorithm type. |
BaseTime | Base UTC time. It cannot be later than the current system time. |
WorkerId | Current node worker ID. |
WorkerIdBitLength / SeqBitLength | Worker ID and sequence bit lengths. |
DataCenterId | Data center ID. |
TimestampType | Timestamp unit. |
Use different WorkerId values for different nodes in a multi-node deployment to avoid ID conflicts.
| Item | Description |
|---|
ForceUpdate | Master switch for force-refreshing built-in data. |
ForceUpdateUsers | Whether to refresh built-in users. |
ForceUpdateRoles | Whether to refresh built-in roles. |
ForceUpdateMenus | Whether to refresh menus. |
ForceUpdateMenuLocales | Whether to refresh menu localization. |
ForceUpdateButtons | Whether to refresh button permissions. |
Back up the database before enabling force refresh in a production system with customized users, roles, or menus.