Skip to content

Commit

Permalink
feat(env): migrated to using env for frequently updated configs
Browse files Browse the repository at this point in the history
  • Loading branch information
arhamj committed Oct 17, 2024
1 parent 48f02dd commit 441a964
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum collectorMode {
export interface Config {
env: string
host: string
dbPath: string
dataLogWrite: boolean
dataLogWriter: {
dirName: string
Expand Down Expand Up @@ -78,6 +79,7 @@ export interface Config {
let config: Config = {
env: process.env.SHARDEUM_COLLECTOR_MODE || envEnum.PROD, //default safe if env is not set
host: process.env.HOST || '127.0.0.1',
dbPath: process.env.COLLECTOR_DB_PATH || "db.sqlite3",
dataLogWrite: false,
dataLogWriter: {
dirName: 'data-logs',
Expand All @@ -91,7 +93,7 @@ let config: Config = {
secretKey: '',
},
hashKey: '69fa4195670576c0160d660c3be36556ff8d504725be8a59b5a96509e0c994bc',
enableCollectorSocketServer: false,
enableCollectorSocketServer: Boolean(process.env.ENABLE_COLLECTOR_SOCKET_SERVER) || false,
port: {
collector: process.env.COLLECTOR_PORT || '4444',
server: process.env.PORT || '6101',
Expand Down Expand Up @@ -119,7 +121,7 @@ let config: Config = {
enableTxHashCache: false,
findTxHashInOriginalTx: false,
enableShardeumIndexer: true,
shardeumIndexerSqlitePath: 'shardeum.sqlite',
shardeumIndexerSqlitePath: process.env.SERVICE_VALIDATOR_DB_PATH || "db.sqlite3",
blockIndexing: {
enabled: true,
blockProductionRate: 6,
Expand Down
2 changes: 1 addition & 1 deletion src/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const isBlockIndexingEnabled = (): boolean => {

export const initializeDB = async (): Promise<void> => {
await db.init({
defaultDbSqlitePath: 'db.sqlite3',
defaultDbSqlitePath: config.dbPath,
enableShardeumIndexer: config.enableShardeumIndexer,
shardeumIndexerSqlitePath: config.shardeumIndexerSqlitePath,
})
Expand Down

0 comments on commit 441a964

Please sign in to comment.