diff options
author | myk bilokonsky <mbilokonsky@gmail.com> | 2017-04-15 14:26:45 +0200 |
---|---|---|
committer | myk bilokonsky <mbilokonsky@gmail.com> | 2017-04-15 14:26:45 +0200 |
commit | a95827489f459e1151393158b2f4238e4bec5ce3 (patch) | |
tree | e4836f9e85f4ae81ac65cfe0d5446442cb05cc96 | |
parent | 4d8f4f9b0c64322977ad31689c17e5b64032047b (diff) |
log output at startup
-rw-r--r-- | index.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/index.js b/index.js index e24ad19..1ef0760 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,13 @@ WHERE favourites_count > ( ) AND created_at > NOW() - INTERVAL '5 days';` +var DB_USER = process.env.DB_USER || 'ambassador'; +var DB_NAME = process.env.DB_NAME || 'mastodon_production'; +var DB_PASSWORD = process.env.DB_PASSWORD || ''; +var DB_HOST = process.env.DB_HOST || '/var/run/postgresql'; +var AMBASSADOR_TOKEN = process.env.AMBASSADOR_TOKEN; +var INSTANCE_HOST = process.env.INSTANCE_HOST; + var config = { user: process.env.DB_USER || 'ambassador', database: process.env.DB_NAME || 'mastodon_production', @@ -23,19 +30,29 @@ var config = { }; +console.dir('STARTING AMBASSADOR'); +console.log('\tDB_USER:', DB_USER); +console.log('\tDB_NAME:', DB_NAME); +console.log('\tDB_PASSWORD:', DB_PASSWORD.split('').map(function() { return "*" }).join('')); +console.log('\tDB_HOST:', DB_HOST); +console.log('\tAMBASSADOR_TOKEN:', AMBASSADOR_TOKEN); +console.log('\tINSTANCE_HOST:', INSTANCE_HOST); + var client = new pg.Client(config); function cycle() { client.connect(function (err) { - if (err) throw err; + if (err) { + return console.error('error connecting to client', err.message); + } client.query(query, [], function (err, result) { if(err) { - return console.error('error running query', err); + return console.error('error running query', err.message); } client.end(function (err) { - if (err) throw err; + console.error('error disconnecting from client', err.message); }); boost(result.rows); @@ -44,8 +61,8 @@ function cycle() { } var M = new mastodon({ - access_token: process.env.AMBASSADOR_TOKEN, - api_url: process.env.INSTANCE_HOST + '/api/v1' + access_token: AMBASSADOR_TOKEN, + api_url: INSTANCE_HOST + '/api/v1' }); var boosted = (function() { |