Initialize db during update
-The initialize_data_startup() function is now being called in the update_explorer script to ensure that new changes to the database structure are automaticaly run after the explorer code is updated
This commit is contained in:
+43
-29
@@ -9,9 +9,20 @@ function exit() {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function compile_css() {
|
function init_database(cb) {
|
||||||
// compile scss to css
|
// compile scss to css
|
||||||
execSync('node ./scripts/compile_css.js', {stdio : 'inherit'});
|
execSync('node ./scripts/compile_css.js', {stdio : 'inherit'});
|
||||||
|
|
||||||
|
const db = require('../lib/database');
|
||||||
|
|
||||||
|
// connect to mongo database
|
||||||
|
db.connect(null, function() {
|
||||||
|
// initialize the database
|
||||||
|
db.initialize_data_startup(function() {
|
||||||
|
// finish the database init
|
||||||
|
return cb(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the script should check for code updates
|
// check if the script should check for code updates
|
||||||
@@ -123,19 +134,19 @@ if (reloadWebserver == true) {
|
|||||||
|
|
||||||
// check if any pm2 pids were active
|
// check if any pm2 pids were active
|
||||||
if (pidActive == true) {
|
if (pidActive == true) {
|
||||||
// compile css
|
// compile css and initialize database
|
||||||
compile_css();
|
init_database(function() {
|
||||||
|
console.log('\nReloading the explorer.. Please wait..\n');
|
||||||
|
|
||||||
console.log('\nReloading the explorer.. Please wait..\n');
|
// reload pm2 using the zero-downtime reload function
|
||||||
|
execSync(`pm2 reload explorer`, {stdio : 'inherit'});
|
||||||
|
|
||||||
// reload pm2 using the zero-downtime reload function
|
// add a new line for better spacing
|
||||||
execSync(`pm2 reload explorer`, {stdio : 'inherit'});
|
console.log('');
|
||||||
|
|
||||||
// add a new line for better spacing
|
// finish the script
|
||||||
console.log('');
|
exit();
|
||||||
|
});
|
||||||
// finish the script
|
|
||||||
exit();
|
|
||||||
} else {
|
} else {
|
||||||
// check if the forever pid file exists and is valid
|
// check if the forever pid file exists and is valid
|
||||||
if (fs.existsSync('./tmp/forever.pid') && lib.is_locked(['forever'], true) == true) {
|
if (fs.existsSync('./tmp/forever.pid') && lib.is_locked(['forever'], true) == true) {
|
||||||
@@ -145,19 +156,19 @@ if (reloadWebserver == true) {
|
|||||||
|
|
||||||
// check if the forever.pid is active
|
// check if the forever.pid is active
|
||||||
if (pidActive == true) {
|
if (pidActive == true) {
|
||||||
// compile css
|
// compile css and initialize database
|
||||||
compile_css();
|
init_database(function() {
|
||||||
|
console.log('\nReloading the explorer.. Please wait..\n');
|
||||||
console.log('\nReloading the explorer.. Please wait..\n');
|
|
||||||
|
|
||||||
// reload forever using the restart function
|
// reload forever using the restart function
|
||||||
execSync(`forever restart explorer`, {stdio : 'inherit'});
|
execSync(`forever restart explorer`, {stdio : 'inherit'});
|
||||||
|
|
||||||
// add a new line for better spacing
|
// add a new line for better spacing
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
// finish the script
|
// finish the script
|
||||||
exit();
|
exit();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
const request = require('postman-request');
|
const request = require('postman-request');
|
||||||
const settings = require('../lib/settings');
|
const settings = require('../lib/settings');
|
||||||
@@ -165,17 +176,20 @@ if (reloadWebserver == true) {
|
|||||||
// try executing the restart explorer api
|
// try executing the restart explorer api
|
||||||
request({uri: `http://localhost:${settings.webserver.port}/system/restartexplorer`, timeout: 1000}, function (error, response, summary) {
|
request({uri: `http://localhost:${settings.webserver.port}/system/restartexplorer`, timeout: 1000}, function (error, response, summary) {
|
||||||
// check if there was an error
|
// check if there was an error
|
||||||
if (error != null)
|
if (error != null) {
|
||||||
console.log('Webserver is not runnning\n');
|
console.log('Webserver is not runnning\n');
|
||||||
else {
|
|
||||||
// compile css
|
|
||||||
compile_css();
|
|
||||||
|
|
||||||
console.log('\nReloading the explorer.. Please wait..\n');
|
// finish the script
|
||||||
|
exit();
|
||||||
|
} else {
|
||||||
|
// compile css and initialize database
|
||||||
|
init_database(function() {
|
||||||
|
console.log('\nReloading the explorer.. Please wait..\n');
|
||||||
|
|
||||||
|
// finish the script
|
||||||
|
exit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish the script
|
|
||||||
exit();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user