Skip to content

Commit

Permalink
[ASI-1007] remove getMode function, default --run-all
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaylor89 committed Apr 8, 2022
1 parent b91e991 commit 2f83fb3
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions creator-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ const connectToDBAndRunMigrations = async () => {
await runDBMigrations()
}

const getMode = () => {
const arg = process.argv[2]
const modes = ['--run-migrations', '--run-app', '--run-all']
if (!modes.includes(arg)) {
return '--run-all'
}
return arg
}

/**
* Setting a different port is necessary for OpenResty to work. If OpenResty
* is enabled, have the app run on port 3000. Else, run on its configured port.
Expand Down Expand Up @@ -100,28 +91,18 @@ const startApp = async () => {
)
}

const mode = getMode()
let appInfo: any
await connectToDBAndRunMigrations()

if (mode === '--run-migrations') {
await connectToDBAndRunMigrations()
process.exit(0)
} else {
if (mode === '--run-all') {
await connectToDBAndRunMigrations()
}

const nodeMode = config.get('devMode') ? 'Dev Mode' : 'Production Mode'
await serviceRegistry.initServices()
logger.info(`Initialized services (Node running in ${nodeMode})`)
const nodeMode = config.get('devMode') ? 'Dev Mode' : 'Production Mode'
await serviceRegistry.initServices()
logger.info(`Initialized services (Node running in ${nodeMode})`)

appInfo = initializeApp(getPort(), serviceRegistry)
logger.info('Initialized app and server')
const appInfo = initializeApp(getPort(), serviceRegistry)
logger.info('Initialized app and server')

// Some Services cannot start until server is up. Start them now
// No need to await on this as this process can take a while and can run in the background
serviceRegistry.initServicesThatRequireServer()
}
// Some Services cannot start until server is up. Start them now
// No need to await on this as this process can take a while and can run in the background
serviceRegistry.initServicesThatRequireServer()

// when app terminates, close down any open DB connections gracefully
ON_DEATH((signal: any, error: any) => {
Expand Down

0 comments on commit 2f83fb3

Please sign in to comment.