mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
eb52cb06bb
refs https://github.com/TryGhost/Ghost/pull/12431 - child_process are more expensive to run comparing to worker_threads (ref. https://wanago.io/2019/05/20/node-js-typescript-14-performance-hooks/) - limiting child process only to sqlite backed instances allows high load servers running with MySQL (most usecases) to continue using worker_threads
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
const config = require('../shared/config');
|
|
|
|
/**
|
|
* If we enable bluebird debug logs we see a huge memory usage.
|
|
* You can reproduce by removing this line and import a big database export into Ghost.
|
|
* `NODE_ENV=development node index.js`
|
|
*/
|
|
process.env.BLUEBIRD_DEBUG = 0;
|
|
|
|
/**
|
|
* Force bthreads to use child_process backend until a worker_thread-compatible version of sqlite3 is published
|
|
* https://github.com/mapbox/node-sqlite3/issues/1386
|
|
*/
|
|
const isSQLite = config.get('database:client') === 'sqlite3';
|
|
if (isSQLite) {
|
|
process.env.BTHREADS_BACKEND = 'child_process';
|
|
}
|
|
|
|
const moment = require('moment-timezone');
|
|
|
|
/**
|
|
* oembed-parser uses promise-wtf to extend the global Promise with .finally
|
|
* - require it before global Bluebird Promise override so that promise-wtf
|
|
* doesn't error due to Bluebird's Promise already having a .finally
|
|
* - https://github.com/ndaidong/promise-wtf/issues/25
|
|
*/
|
|
const {extract, hasProvider} = require('oembed-parser'); // eslint-disable-line
|
|
|
|
/**
|
|
* force UTC
|
|
* - you can require moment or moment-timezone, both is configured to UTC
|
|
* - you are allowed to use new Date() to instantiate datetime values for models, because they are transformed into UTC in the model layer
|
|
* - be careful when not working with models, every value from the native JS Date is local TZ
|
|
* - be careful when you work with date operations, therefor always wrap a date into moment
|
|
*/
|
|
moment.tz.setDefault('UTC');
|