refactor db connection string
This commit is contained in:
parent
944de6fab0
commit
91e0fed95d
9 changed files with 47 additions and 82 deletions
29
lib/options.js
Normal file
29
lib/options.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
'use strict'
|
||||
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var os = require('os')
|
||||
|
||||
var options
|
||||
var configPath
|
||||
|
||||
try {
|
||||
configPath = '/etc/lamassu.json'
|
||||
options = JSON.parse(fs.readFileSync(configPath))
|
||||
} catch (err) {
|
||||
try {
|
||||
configPath = path.resolve(os.homedir(), '.lamassu', 'lamassu.json')
|
||||
options = JSON.parse(fs.readFileSync(configPath))
|
||||
} catch (err2) {
|
||||
console.log('Missing configuration file -- exiting.')
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
var psqlUrl = options.postgres
|
||||
if (!psqlUrl) {
|
||||
console.log('Missing postgres entry in configuration file: %s', configPath)
|
||||
process.exit(2)
|
||||
}
|
||||
|
||||
module.exports = options
|
||||
Loading…
Add table
Add a link
Reference in a new issue