mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-10-30 23:33:34 +00:00 
			
		
		
		
	Split out docs, better error handling when database config doesn't exist
This commit is contained in:
		| @@ -1,12 +1,12 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| let config = require('config'); | ||||
| const config = require('config'); | ||||
|  | ||||
| if (!config.has('database')) { | ||||
|     throw new Error('Database config does not exist! Read the README for instructions.'); | ||||
|     throw new Error('Database config does not exist! Please read the instructions: https://github.com/jc21/nginx-proxy-manager/blob/master/doc/INSTALL.md'); | ||||
| } | ||||
|  | ||||
| let knex = require('knex')({ | ||||
| let data = { | ||||
|     client:     config.database.engine, | ||||
|     connection: { | ||||
|         host:     config.database.host, | ||||
| @@ -18,6 +18,10 @@ let knex = require('knex')({ | ||||
|     migrations: { | ||||
|         tableName: 'migrations' | ||||
|     } | ||||
| }); | ||||
| }; | ||||
|  | ||||
| module.exports = knex; | ||||
| if (typeof config.database.version !== 'undefined') { | ||||
|     data.version = config.database.version; | ||||
| } | ||||
|  | ||||
| module.exports = require('knex')(data); | ||||
|   | ||||
| @@ -2,20 +2,14 @@ | ||||
|  | ||||
| 'use strict'; | ||||
|  | ||||
| const config       = require('config'); | ||||
| const app          = require('./app'); | ||||
| const logger       = require('./logger').global; | ||||
| const migrate      = require('./migrate'); | ||||
| const setup        = require('./setup'); | ||||
| const apiValidator = require('./lib/validator/api'); | ||||
|  | ||||
| let port = process.env.PORT || 81; | ||||
|  | ||||
| if (config.has('port')) { | ||||
|     port = config.get('port'); | ||||
| } | ||||
| const logger = require('./logger').global; | ||||
|  | ||||
| function appStart () { | ||||
|     const migrate      = require('./migrate'); | ||||
|     const setup        = require('./setup'); | ||||
|     const app          = require('./app'); | ||||
|     const apiValidator = require('./lib/validator/api'); | ||||
|  | ||||
|     return migrate.latest() | ||||
|         .then(() => { | ||||
|             return setup(); | ||||
| @@ -24,8 +18,8 @@ function appStart () { | ||||
|             return apiValidator.loadSchemas; | ||||
|         }) | ||||
|         .then(() => { | ||||
|             const server = app.listen(port, () => { | ||||
|                 logger.info('PID ' + process.pid + ' listening on port ' + port + ' ...'); | ||||
|             const server = app.listen(81, () => { | ||||
|                 logger.info('PID ' + process.pid + ' listening on port 81 ...'); | ||||
|  | ||||
|                 process.on('SIGTERM', () => { | ||||
|                     logger.info('PID ' + process.pid + ' received SIGTERM'); | ||||
| @@ -42,4 +36,9 @@ function appStart () { | ||||
|         }); | ||||
| } | ||||
|  | ||||
| appStart(); | ||||
| try { | ||||
|     appStart(); | ||||
| } catch (err) { | ||||
|     logger.error(err.message); | ||||
|     process.exit(1); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user