From ec09aaeb7db4947041b53bc14dfd3019a97c1154 Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Wed, 27 Apr 2016 16:32:37 +0100 Subject: [PATCH] fix up notify.js and README --- README.md | 2 +- dev/notify.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e7390b3a..91053371 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ npm install ## Configuration ```bash -bin/ssu config smtp2go user pass toEmail +bin/ssu config smtp2go user pass fromEmail toEmail bin/ssu config twilio accountSid authToken fromNumber toNumber bin/ssu set sms twilio bin/ssu set email smtp2go diff --git a/dev/notify.js b/dev/notify.js index 1edb5276..5d3dd3f1 100644 --- a/dev/notify.js +++ b/dev/notify.js @@ -1,5 +1,6 @@ require('es6-promise').polyfill() +var fs = require('fs') var notifier = require('../lib/notifier') var db = require('../lib/postgresql_interface') @@ -10,7 +11,14 @@ function getBalances () { ] } -db.init('psql://lamassu:lamassu@localhost/lamassu') +var psqlUrl +try { + psqlUrl = process.env.DATABASE_URL || JSON.parse(fs.readFileSync('/etc/lamassu.json')).postgresql +} catch (ex) { + psqlUrl = 'psql://lamassu:lamassu@localhost/lamassu' +} + +db.init(psqlUrl) notifier.init(db, getBalances, {lowBalanceThreshold: 10}) console.log('DEBUG0') notifier.checkStatus()