mirror of
https://github.com/jc21/nginx-proxy-manager.git
synced 2024-08-30 18:22:48 +00:00
Fixes #11 - After creating keys the app needs to completely restart due to aggressive module caching
This commit is contained in:
parent
4fe26ec4c0
commit
efa1424cad
@ -3,4 +3,9 @@
|
|||||||
mkdir -p /data/letsencrypt-acme-challenge
|
mkdir -p /data/letsencrypt-acme-challenge
|
||||||
|
|
||||||
cd /app
|
cd /app
|
||||||
node --abort_on_uncaught_exception --max_old_space_size=250 /app/src/backend/index.js
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
node --abort_on_uncaught_exception --max_old_space_size=250 /app/src/backend/index.js
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const logger = require('./logger').import;
|
const logger = require('./logger').import;
|
||||||
const utils = require('./lib/utils');
|
const utils = require('./lib/utils');
|
||||||
const batchflow = require('batchflow');
|
const batchflow = require('batchflow');
|
||||||
|
const debug_mode = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
const internalProxyHost = require('./internal/proxy-host');
|
const internalProxyHost = require('./internal/proxy-host');
|
||||||
const internalRedirectionHost = require('./internal/redirection-host');
|
const internalRedirectionHost = require('./internal/redirection-host');
|
||||||
@ -534,6 +535,10 @@ module.exports = function () {
|
|||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (debug_mode) {
|
||||||
|
logger.debug('Importer skipped');
|
||||||
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,4 +8,5 @@ module.exports = {
|
|||||||
nginx: new Signale({scope: 'Nginx '}),
|
nginx: new Signale({scope: 'Nginx '}),
|
||||||
ssl: new Signale({scope: 'SSL '}),
|
ssl: new Signale({scope: 'SSL '}),
|
||||||
import: new Signale({scope: 'Importer'}),
|
import: new Signale({scope: 'Importer'}),
|
||||||
|
setup: new Signale({scope: 'Setup '})
|
||||||
};
|
};
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const NodeRSA = require('node-rsa');
|
const NodeRSA = require('node-rsa');
|
||||||
const config = require('config');
|
const config = require('config');
|
||||||
const logger = require('./logger').global;
|
const logger = require('./logger').setup;
|
||||||
const userModel = require('./models/user');
|
const userModel = require('./models/user');
|
||||||
const userPermissionModel = require('./models/user_permission');
|
const userPermissionModel = require('./models/user_permission');
|
||||||
const authModel = require('./models/auth');
|
const authModel = require('./models/auth');
|
||||||
|
const debug_mode = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -22,6 +23,9 @@ module.exports = function () {
|
|||||||
config_data = require(filename);
|
config_data = require(filename);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
if (debug_mode) {
|
||||||
|
logger.debug(filename + ' config file could not be required');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now create the keys and save them in the config.
|
// Now create the keys and save them in the config.
|
||||||
@ -40,12 +44,18 @@ module.exports = function () {
|
|||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
logger.info('Wrote JWT key pair to config file: ' + filename);
|
logger.info('Wrote JWT key pair to config file: ' + filename);
|
||||||
config.util.loadFileConfigs();
|
|
||||||
resolve();
|
logger.warn('Restarting interface to apply new configuration');
|
||||||
|
process.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// JWT key pair exists
|
// JWT key pair exists
|
||||||
|
if (debug_mode) {
|
||||||
|
logger.debug('JWT Keypair already exists');
|
||||||
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -54,49 +64,54 @@ module.exports = function () {
|
|||||||
.query()
|
.query()
|
||||||
.select(userModel.raw('COUNT(`id`) as `count`'))
|
.select(userModel.raw('COUNT(`id`) as `count`'))
|
||||||
.where('is_deleted', 0)
|
.where('is_deleted', 0)
|
||||||
.first('count')
|
.first();
|
||||||
.then(row => {
|
})
|
||||||
if (!row.count) {
|
.then(row => {
|
||||||
// Create a new user and set password
|
if (!row.count) {
|
||||||
logger.info('Creating a new user: admin@example.com with password: changeme');
|
// Create a new user and set password
|
||||||
|
logger.info('Creating a new user: admin@example.com with password: changeme');
|
||||||
|
|
||||||
let data = {
|
let data = {
|
||||||
is_deleted: 0,
|
is_deleted: 0,
|
||||||
email: 'admin@example.com',
|
email: 'admin@example.com',
|
||||||
name: 'Administrator',
|
name: 'Administrator',
|
||||||
nickname: 'Admin',
|
nickname: 'Admin',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
roles: ['admin']
|
roles: ['admin']
|
||||||
};
|
};
|
||||||
|
|
||||||
return userModel
|
return userModel
|
||||||
|
.query()
|
||||||
|
.insertAndFetch(data)
|
||||||
|
.then(user => {
|
||||||
|
return authModel
|
||||||
.query()
|
.query()
|
||||||
.insertAndFetch(data)
|
.insert({
|
||||||
.then(user => {
|
user_id: user.id,
|
||||||
return authModel
|
type: 'password',
|
||||||
|
secret: 'changeme',
|
||||||
|
meta: {}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return userPermissionModel
|
||||||
.query()
|
.query()
|
||||||
.insert({
|
.insert({
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
type: 'password',
|
visibility: 'all',
|
||||||
secret: 'changeme',
|
proxy_hosts: 'manage',
|
||||||
meta: {}
|
redirection_hosts: 'manage',
|
||||||
})
|
dead_hosts: 'manage',
|
||||||
.then(() => {
|
streams: 'manage',
|
||||||
return userPermissionModel
|
access_lists: 'manage',
|
||||||
.query()
|
certificates: 'manage'
|
||||||
.insert({
|
|
||||||
user_id: user.id,
|
|
||||||
visibility: 'all',
|
|
||||||
proxy_hosts: 'manage',
|
|
||||||
redirection_hosts: 'manage',
|
|
||||||
dead_hosts: 'manage',
|
|
||||||
streams: 'manage',
|
|
||||||
access_lists: 'manage',
|
|
||||||
certificates: 'manage'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
});
|
.then(() => {
|
||||||
|
logger.info('Initial setup completed');
|
||||||
|
});
|
||||||
|
} else if (debug_mode) {
|
||||||
|
logger.debug('Admin user setup not required');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user