Skip to content

Commit

Permalink
agent: fix argument review on both startup commands
Browse files Browse the repository at this point in the history
It should run in 'start', not 'start-multiple'
  • Loading branch information
tilacog committed Jul 11, 2023
1 parent 9a4eea0 commit e0d72c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
19 changes: 4 additions & 15 deletions packages/indexer-agent/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Argv } from 'yargs'
import { SequelizeStorage, Umzug } from 'umzug'
import {
connectDatabase,
createLogger,
createMetrics,
createMetricsServer,
formatGRT,
Expand Down Expand Up @@ -378,20 +377,8 @@ export async function createNetworkSpecification(
export async function run(
argv: AgentOptions,
networkSpecifications: spec.NetworkSpecification[],
logger: Logger,
): Promise<void> {
const logger = createLogger({
name: 'IndexerAgent',
async: false,
level: argv.logLevel,
})
// --------------------------------------------------------------------------------
// * CLI Argument review
//
// Note: it only lives here and not on yargs.check because we don't have a logger in
// that context
// --------------------------------------------------------------------------------
reviewArgumentsForWarnings(argv, logger)

// --------------------------------------------------------------------------------
// * Configure event listeners for unhandled promise rejections and uncaught
// exceptions.
Expand Down Expand Up @@ -600,7 +587,9 @@ export async function run(

// Review CLI arguments, emit non-interrupting warnings about expected behavior.
// Perform this check immediately after parsing the command line arguments.
function reviewArgumentsForWarnings(argv: AgentOptions, logger: Logger) {
// Ideally, this check could be made inside yargs.check, but we can't access a Logger
// instance in that context.
export function reviewArgumentsForWarnings(argv: AgentOptions, logger: Logger) {
const {
gasIncreaseTimeout,
gasIncreaseFactor,
Expand Down
14 changes: 10 additions & 4 deletions packages/indexer-agent/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createLogger } from '@graphprotocol/common-ts'
import * as yargs from 'yargs'
import { inspect } from 'util'
import { specification as spec } from '@graphprotocol/indexer-common'
import {
start,
createNetworkSpecification,
reviewArgumentsForWarnings,
AgentOptions,
run,
} from './commands/start'
Expand Down Expand Up @@ -36,12 +36,18 @@ function parseArguments(): AgentOptions {
}

async function processArgumentsAndRun(args: AgentOptions): Promise<void> {
const logger = createLogger({
name: 'IndexerAgent',
async: false,
level: args.logLevel,
})
if (args['_'].includes('start')) {
reviewArgumentsForWarnings(args, logger)
const specification = await createNetworkSpecification(args)
await run(args, [specification])
await run(args, [specification], logger)
} else if (args['_'].includes('start-multiple')) {
const specifications = parseNetworkSpecifications(args)
await run(args, specifications)
await run(args, specifications, logger)
} else {
throw new Error('Invalid command line usage for Indexer Agent')
}
Expand Down

0 comments on commit e0d72c9

Please sign in to comment.