2021-10-08 12:03:37 -07:00
|
|
|
/* eslint-disable no-unused-vars */
|
2021-10-05 06:52:17 -07:00
|
|
|
/**
|
|
|
|
* Pricecaster Service.
|
|
|
|
*
|
2021-10-08 12:03:37 -07:00
|
|
|
* Main program file.
|
2021-10-05 06:52:17 -07:00
|
|
|
*
|
|
|
|
* (c) 2021 Randlabs, Inc.
|
|
|
|
*/
|
|
|
|
|
2021-10-12 06:37:11 -07:00
|
|
|
import * as Config from '@randlabs/js-config-reader'
|
|
|
|
import { IAppSettings } from './common/settings'
|
|
|
|
import { exit } from 'process'
|
2021-11-10 09:46:46 -08:00
|
|
|
import { PriceKeeperEngine } from './engine/PriceKeeperEngine'
|
|
|
|
import { WormholeClientEngine } from './engine/WormholeEngine'
|
|
|
|
const charm = require('charm')();
|
2021-10-07 10:41:19 -07:00
|
|
|
|
2021-10-08 12:03:37 -07:00
|
|
|
(async () => {
|
|
|
|
charm.pipe(process.stdout)
|
|
|
|
charm.reset()
|
2021-10-12 06:37:11 -07:00
|
|
|
charm.foreground('cyan').display('bright')
|
2021-11-10 09:46:46 -08:00
|
|
|
console.log('Pricecaster Service Backend -- (c) 2021 Randlabs, Inc.\n')
|
2021-10-12 06:37:11 -07:00
|
|
|
charm.foreground('white')
|
2021-10-08 12:03:37 -07:00
|
|
|
|
2021-10-12 06:37:11 -07:00
|
|
|
let settings: IAppSettings
|
|
|
|
try {
|
|
|
|
await Config.initialize<IAppSettings>({ envVar: 'PRICECASTER_SETTINGS' })
|
|
|
|
settings = Config.get<IAppSettings>()
|
|
|
|
} catch (e: any) {
|
|
|
|
console.error('Cannot initialize configuration: ' + e.toString())
|
|
|
|
exit(1)
|
|
|
|
}
|
|
|
|
|
2021-11-10 09:46:46 -08:00
|
|
|
let engine
|
|
|
|
switch (settings.mode) {
|
|
|
|
case 'pkeeper':
|
|
|
|
engine = new PriceKeeperEngine(settings)
|
|
|
|
break
|
2021-10-12 06:37:11 -07:00
|
|
|
|
2021-11-10 09:46:46 -08:00
|
|
|
case 'wormhole-client':
|
|
|
|
engine = new WormholeClientEngine(settings)
|
|
|
|
break
|
2021-10-08 12:03:37 -07:00
|
|
|
|
2021-11-10 09:46:46 -08:00
|
|
|
default:
|
|
|
|
console.error('Invalid specified mode in settings')
|
|
|
|
exit(2)
|
2021-10-08 12:03:37 -07:00
|
|
|
}
|
2021-10-07 10:41:19 -07:00
|
|
|
|
2021-11-10 09:46:46 -08:00
|
|
|
engine.start()
|
2021-10-08 12:03:37 -07:00
|
|
|
})()
|