Destroying knex when done to ensure process exit.
This commit is contained in:
26
src/app.js
26
src/app.js
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const log = require('why-is-node-running');
|
||||
const blessed = require('neo-blessed');
|
||||
const clipboard = require('clipboardy');
|
||||
|
||||
@@ -44,24 +43,27 @@ function getMethod() {
|
||||
async function init() {
|
||||
const screen = argv.render && !argv.filename && initScreen();
|
||||
|
||||
|
||||
try {
|
||||
const method = getMethod();
|
||||
const result = await method.fetch();
|
||||
|
||||
if (argv.copy && result.copy) {
|
||||
clipboard.writeSync(result.copy);
|
||||
console.log(`Result copied to clipboard: ${result.copy}`);
|
||||
}
|
||||
if (result) {
|
||||
if (argv.copy && result.copy) {
|
||||
clipboard.writeSync(result.copy);
|
||||
console.log(`Result copied to clipboard: ${result.copy}`);
|
||||
}
|
||||
|
||||
if (argv.filename && result.filename) {
|
||||
console.log(result.filename);
|
||||
if (argv.filename && result.filename) {
|
||||
console.log(result.filename);
|
||||
|
||||
setTimeout(() => log(), 5000);
|
||||
return;
|
||||
}
|
||||
// setTimeout(() => log(), 5000);
|
||||
return;
|
||||
}
|
||||
|
||||
if (argv.render) {
|
||||
method.render(result, screen);
|
||||
if (argv.render) {
|
||||
method.render(result, screen);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(argv.debug ? error : error.message);
|
||||
|
||||
@@ -176,6 +176,8 @@ async function fetchReleases() {
|
||||
return [];
|
||||
}));
|
||||
|
||||
knex.destroy();
|
||||
|
||||
const accumulatedScenes = scenesPerSite.reduce((acc, siteScenes) => ([...acc, ...siteScenes]), []);
|
||||
const sortedScenes = accumulatedScenes.sort(({ date: dateA }, { date: dateB }) => moment(dateB).diff(dateA));
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ async function fetchScene(url) {
|
||||
const scene = await scraper.fetchScene(url, site);
|
||||
const filename = deriveFilename(scene);
|
||||
|
||||
knex.destroy();
|
||||
|
||||
return {
|
||||
...scene,
|
||||
filename,
|
||||
|
||||
Reference in New Issue
Block a user