diff --git a/index.js b/index.js index 2c88443..576d4b1 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,9 @@ 'use strict'; const Feeds = require('./src/Feeds'); -const db = require('./src/db')(); const run = function() { + const db = require('./src/db')(); return Feeds.get(db).then((feeds) => { return feeds.run().then(() => { return feeds.cleanup(); @@ -16,9 +16,9 @@ const run = function() { module.exports = { handler: (event, context, callback) => { run().then(() => { - callback(); + context.done(); }).catch((err) => { - callback(err); + context.done(err); }); } }; diff --git a/src/db.js b/src/db.js index cc8a48c..dfc8cd4 100644 --- a/src/db.js +++ b/src/db.js @@ -28,6 +28,7 @@ module.exports = function() { return new Promise((resolve, reject) => { pool.end((err) => { if (err) { return reject(err); } + console.log('Closing database.'); return resolve(); }); });