Improve checks
This commit is contained in:
parent
9acd329c3d
commit
ac13aee9b4
@ -1,10 +1,11 @@
|
||||
const fs = require('fs-extra')
|
||||
const fs = require('fs')
|
||||
const bodyParser = require('body-parser')
|
||||
const cors = require('cors')
|
||||
const express = require('express')
|
||||
|
||||
const logger = require('./core/logger')
|
||||
|
||||
|
||||
/*******************************************
|
||||
|
||||
SEE http://gitlab.ndda.fr/philc/apixtribe/-/wikis/HOWTOoverview
|
||||
@ -12,18 +13,26 @@ const logger = require('./core/logger')
|
||||
|
||||
*********************************************/
|
||||
// check setup*
|
||||
/**
|
||||
if( !fs.existsSync( '/etc/nginx/nginx.conf' ) ) {
|
||||
logger.info( '\x1b[31m Check documentation, nginx have to be installed on this server first, no /etc/nginx/nginx.conf available, install then rerun yarn command.' );
|
||||
process.exit();
|
||||
}
|
||||
*/
|
||||
if (!fs.existsSync('./tribes/townconf.js')) {
|
||||
logger.info('\x1b[42m####################################\nWellcome into apixtribe, you need to init your town by "yarn setup" the first time . \nCheck README\'s project to learn more. more.\n #####################################\x1b[0m')
|
||||
process.exit()
|
||||
|
||||
fs.stat('/etc/nginx/nginx.conf', (err, stats) => {
|
||||
if (err === null) {
|
||||
logger.debug(`File exists.`)
|
||||
} else if (err.code === 'ENOENT') {
|
||||
logger.error('Check documentation, nginx have to be installed on this server first, no /etc/nginx/nginx.conf available, install then rerun yarn command.')
|
||||
process.exit(1)
|
||||
} else {
|
||||
logger.error(`Exception: ` + err)
|
||||
process.exit(1)
|
||||
}
|
||||
})
|
||||
|
||||
// config.js exist in any case from Setup.checkinit();
|
||||
try {
|
||||
const config = require('./tribes/townconf.js')
|
||||
} catch (err) {
|
||||
logger.error('Welcome into apixtribe, you need to init your town by "yarn setup" the first time . Check README\'s project to learn more. more.')
|
||||
process.exit(1)
|
||||
}
|
||||
// Tribes allow to get local apixtribe instance context
|
||||
// dataclient .tribeids [] .DOMs [] .routes (plugins {url:name route:path}) .appname {tribeid:[website]}
|
||||
const dataclient = require('./models/Tribes')
|
||||
@ -103,7 +112,7 @@ dataclient.routes.forEach(r => {
|
||||
try {
|
||||
app.use(r.url, require(r.route))
|
||||
} catch (err) {
|
||||
logger.error(`\x1b[31m!!! WARNING issue with route ${r.route} from ${r.url} check err if route is key then solve err, if not just be aware that this route won't work on your server. If you are not the maintainer and no turn around please contact the email maintainer.\x1b[0m`)
|
||||
logger.error(`WARNING issue with route ${r.route} from ${r.url} check err if route is key then solve err, if not just be aware that this route won't work on your server. If you are not the maintainer and no turn around please contact the email maintainer.`)
|
||||
logger.error('raise err-:', err)
|
||||
}
|
||||
})
|
||||
@ -120,4 +129,4 @@ if( config.withssl === "YES" ) {
|
||||
httpsServer.setTimeout( config.settimeout );
|
||||
}; */
|
||||
|
||||
logger.info('\x1b[42m\x1b[37m', "Made with love for people's freedom, enjoy !!!", '\x1b[0m')
|
||||
logger.info("Made with love for people's freedom, enjoy !!!")
|
||||
|
Loading…
Reference in New Issue
Block a user