Skip to content

Commit

Permalink
fix: only load scanner if not mock
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelTaranto committed Jun 6, 2024
1 parent 5ceaef7 commit dc53da8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bin/lamassu-machine
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require('../lib/logging')
var minimist = require('minimist')
var Brain = require('../lib/brain')
var Configuration = require('../lib/configuration.js')
const scanner = require('../lib/scanner')
let scanner = null

var bailed = false
var brain = null
Expand All @@ -33,6 +33,12 @@ function startBrain () {
var config = Configuration.loadConfig(commandLine)

brain = new Brain(config)

const isGenmegaMachine = config.cryptomatMaker === 'genmega'
this.scanner = config.mockCam
? require('../lib/mocks/scanner')
: require(`../lib/${isGenmegaMachine ? 'scanner-genmega' : 'scanner'}`)

brain.on('error', bail)
brain.run()
}
Expand All @@ -47,7 +53,7 @@ process.on('uncaughtException', err => {
})
process.on('unhandledRejection', console.log)
process.on('exit', function () {
scanner.cancel()
if (scanner) scanner.cancel()
console.log('lamassu-machine exiting')
})

Expand Down

0 comments on commit dc53da8

Please sign in to comment.