Fixes in reports (generating a CSV).

Added caching of generated images in mosaico handler.
Various other fixes.
This commit is contained in:
Tomas Bures 2019-04-22 02:41:40 +02:00
parent 055c4c6b51
commit 66702b5edc
39 changed files with 545 additions and 278 deletions

View file

@ -19,11 +19,13 @@ const reportProcessor = require('./lib/report-processor');
const executor = require('./lib/executor');
const privilegeHelpers = require('./lib/privilege-helpers');
const knex = require('./lib/knex');
const bluebird = require('bluebird');
const shares = require('./models/shares');
const { AppType } = require('../shared/app');
const builtinZoneMta = require('./lib/builtin-zone-mta');
const { uploadedFilesDir } = require('./lib/file-helpers');
const { reportFilesDir } = require('./lib/report-helpers');
const { filesDir } = require('./models/files');
const trustedPort = config.www.trustedPort;
@ -36,8 +38,8 @@ if (config.title) {
}
function startHTTPServer(appType, appName, port, callback) {
const app = appBuilder.createApp(appType);
async function startHTTPServer(appType, appName, port) {
const app = await appBuilder.createApp(appType);
app.set('port', port);
const server = http.createServer(app);
@ -68,81 +70,58 @@ function startHTTPServer(appType, appName, port, callback) {
log.info('Express', 'WWW server [%s] listening on %s', appName, bind);
});
server.listen({port, host}, callback);
const serverListenAsync = bluebird.promisify(server.listen.bind(server));
await serverListenAsync({port, host});
}
// ---------------------------------------------------------------------------------------
// Start the whole circus here
// Start the whole circus
// ---------------------------------------------------------------------------------------
dbcheck(err => { // Check if database needs upgrading before starting the server - legacy migration first
if (err) {
log.error('DB', err.message || err);
return process.exit(1);
}
async function init() {
await dbcheck();
knex.migrate.latest() // And now the current migration with Knex
await knex.migrate.latest(); // And now the current migration with Knex
.then(() => shares.regenerateRoleNamesTable())
.then(() => shares.rebuildPermissions())
await shares.regenerateRoleNamesTable();
await shares.rebuildPermissions();
/* Simplified startup without services - only for debugging the UI and models
.then(() =>
startHTTPServer(AppType.TRUSTED, 'trusted', trustedPort, () =>
startHTTPServer(AppType.SANDBOXED, 'sandbox', sandboxPort, () =>
startHTTPServer(AppType.PUBLIC, 'public', publicPort, async () => {
/*
await executor.spawn();
await testServer.spawn();
await verpServer.spawn();
await builtinZoneMta.spawn();
*/
await privilegeHelpers.ensureMailtrainDir(uploadedFilesDir);
await startHTTPServer(AppType.TRUSTED, 'trusted', trustedPort);
await startHTTPServer(AppType.SANDBOXED, 'sandbox', sandboxPort);
await startHTTPServer(AppType.PUBLIC, 'public', publicPort);
privilegeHelpers.dropRootPrivileges();
await privilegeHelpers.ensureMailtrainDir(filesDir);
await privilegeHelpers.ensureMailtrainDir(uploadedFilesDir);
await privilegeHelpers.ensureMailtrainDir(reportFilesDir);
tzupdate.start();
privilegeHelpers.dropRootPrivileges();
log.info('Service', 'All services started');
appBuilder.setReady();
})
)
)
);
*/
/*
tzupdate.start();
.then(() =>
executor.spawn(() =>
testServer(() =>
verpServer(() =>
builtinZoneMta.spawn(() =>
startHTTPServer(AppType.TRUSTED, 'trusted', trustedPort, () =>
startHTTPServer(AppType.SANDBOXED, 'sandbox', sandboxPort, () =>
startHTTPServer(AppType.PUBLIC, 'public', publicPort, async () => {
await importer.spawn();
await feedcheck.spawn();
await senders.spawn();
await privilegeHelpers.ensureMailtrainDir(filesDir);
await privilegeHelpers.ensureMailtrainDir(uploadedFilesDir);
triggers.start();
gdprCleanup.start();
privilegeHelpers.dropRootPrivileges();
await postfixBounceServer.spawn();
tzupdate.start();
await reportProcessor.init();
*/
importer.spawn(() =>
feedcheck.spawn(() =>
senders.spawn(() => {
triggers.start();
gdprCleanup.start();
log.info('Service', 'All services started');
appBuilder.setReady();
}
postfixBounceServer(async () => {
await reportProcessor.init();
log.info('Service', 'All services started');
appBuilder.setReady();
});
})
)
);
})
)
)
)
)
)
)
);
});
init().catch(err => {log.error('', err); process.exit(1); });