From fa5231c587469def3fe02bdca51ceb914a6be88a Mon Sep 17 00:00:00 2001 From: Morgan Hayes Date: Fri, 2 Apr 2021 15:44:39 -0600 Subject: [PATCH 1/2] Update index.js Improved connection to PG with logging error. --- bin/index.js | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/bin/index.js b/bin/index.js index 43b4c20..1ee128d 100755 --- a/bin/index.js +++ b/bin/index.js @@ -1,10 +1,9 @@ #!/usr/bin/env node -var pg = require('pg'); +const { Pool, Client } = require('pg') var PostgresCouchDB = require('../lib'); - - +// old notes from original branch //Note there is an error in the simple example which i have not tracked down/fixed //yet it will not restart the stream from where it left off if the feeder is stopped // @@ -14,33 +13,29 @@ var PostgresCouchDB = require('../lib'); var settings = { couchdb: { - url: 'http://192.168.3.21:5984', - pgtable: 'example', - database: 'example' + url: 'http://administrator:Western5280@cce-server02.office.ccenttcs.com:5984', + pgtable: 'couch_import', + database: 'tcsmaster' } }; -pgclient = new pg.Client("postgres://mike@localhost/pgdatabase"); - - -pgclient.connect(function(err) { - if (err) { - if(err.code == 'ECONNREFUSED'){ //try to catch here but i dont think works - console.error('ERROR: Connection to postgres refused', err); - }else{ - console.error('ERROR: Could not connect to postgres', err); - } - process.exit(); - } else { - console.log('Connected to postgres'); - } - }) ; - - -initial_since = get_initial_since(settings.couchdb.pgtable); - -createImporter(); - +var pgclient = new Client({ + user: 'morgan', + host: 'cce-server02.office.ccenttcs.com', + database: 'tcs_import', + password: 'Tg8856PG', + port: 5432, +}); + +pgclient + .connect() + .then(() => { + console.log('Connected to postgres'); + + initial_since = get_initial_since(settings.couchdb.pgtable); + createImporter(); + }) + .catch(err => console.error('connection error', err.stack)) function createImporter(){ settings.since = initial_since; From ae049eb3610cc07ac6ec7778e8db77519a05749d Mon Sep 17 00:00:00 2001 From: Morgan Hayes Date: Wed, 7 Apr 2021 08:26:41 -0600 Subject: [PATCH 2/2] Update index.js --- bin/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/index.js b/bin/index.js index 1ee128d..7593014 100755 --- a/bin/index.js +++ b/bin/index.js @@ -13,17 +13,17 @@ var PostgresCouchDB = require('../lib'); var settings = { couchdb: { - url: 'http://administrator:Western5280@cce-server02.office.ccenttcs.com:5984', + url: 'http://user:pass@ipAddress:5984', pgtable: 'couch_import', database: 'tcsmaster' } }; var pgclient = new Client({ - user: 'morgan', - host: 'cce-server02.office.ccenttcs.com', + user: 'user', + host: 'ipAddress', database: 'tcs_import', - password: 'Tg8856PG', + password: 'pass', port: 5432, });