Merge branch 'development' of github.com:Mailtrain-org/mailtrain into development
This commit is contained in:
commit
97bbac8698
2 changed files with 40 additions and 20 deletions
|
@ -62,6 +62,13 @@ const interoperableErrors = require('../shared/interoperable-errors');
|
||||||
const { getTrustedUrl } = require('./lib/urls');
|
const { getTrustedUrl } = require('./lib/urls');
|
||||||
const { AppType } = require('../shared/app');
|
const { AppType } = require('../shared/app');
|
||||||
|
|
||||||
|
|
||||||
|
let isReady = false;
|
||||||
|
function setReady() {
|
||||||
|
isReady = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
hbs.registerPartials(__dirname + '/views/partials');
|
hbs.registerPartials(__dirname + '/views/partials');
|
||||||
hbs.registerPartials(__dirname + '/views/subscription/partials/');
|
hbs.registerPartials(__dirname + '/views/subscription/partials/');
|
||||||
|
|
||||||
|
@ -201,6 +208,19 @@ function createApp(appType) {
|
||||||
limit: config.www.postSize
|
limit: config.www.postSize
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
if (isReady) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
res.status(500);
|
||||||
|
res.render('error', {
|
||||||
|
message: 'Mailtrain is starting. Try again after a few seconds.',
|
||||||
|
error: {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (appType === AppType.TRUSTED) {
|
if (appType === AppType.TRUSTED) {
|
||||||
passport.setupRegularAuth(app);
|
passport.setupRegularAuth(app);
|
||||||
} else if (appType === AppType.SANDBOXED) {
|
} else if (appType === AppType.SANDBOXED) {
|
||||||
|
@ -385,3 +405,4 @@ function createApp(appType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.createApp = createApp;
|
module.exports.createApp = createApp;
|
||||||
|
module.exports.setReady = setReady;
|
||||||
|
|
|
@ -92,37 +92,36 @@ dbcheck(err => { // Check if database needs upgrading before starting the server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.then(() =>
|
.then(() =>
|
||||||
executor.spawn(() => {
|
executor.spawn(() =>
|
||||||
testServer(() => {
|
testServer(() =>
|
||||||
verpServer(() => {
|
verpServer(() =>
|
||||||
startHTTPServer(AppType.TRUSTED, 'trusted', trustedPort, () => {
|
startHTTPServer(AppType.TRUSTED, 'trusted', trustedPort, () =>
|
||||||
startHTTPServer(AppType.SANDBOXED, 'sandbox', sandboxPort, () => {
|
startHTTPServer(AppType.SANDBOXED, 'sandbox', sandboxPort, () =>
|
||||||
startHTTPServer(AppType.PUBLIC, 'public', publicPort, () => {
|
startHTTPServer(AppType.PUBLIC, 'public', publicPort, () => {
|
||||||
privilegeHelpers.dropRootPrivileges();
|
privilegeHelpers.dropRootPrivileges();
|
||||||
|
|
||||||
tzupdate.start();
|
tzupdate.start();
|
||||||
|
|
||||||
importer.spawn(() => {
|
importer.spawn(() =>
|
||||||
feedcheck.spawn(() => {
|
feedcheck.spawn(() =>
|
||||||
senders.spawn(() => {
|
senders.spawn(() => {
|
||||||
triggers.start();
|
triggers.start();
|
||||||
gdprCleanup.start();
|
gdprCleanup.start();
|
||||||
|
|
||||||
postfixBounceServer(async () => {
|
postfixBounceServer(async () => {
|
||||||
(async () => {
|
|
||||||
await reportProcessor.init();
|
await reportProcessor.init();
|
||||||
log.info('Service', 'All services started');
|
log.info('Service', 'All services started');
|
||||||
})();
|
appBuilder.setReady();
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue