Added RunOnServerStarted, RunOnServerUpdated, RunOnServerError options. #3768
This commit is contained in:
parent
a1f84ee589
commit
e3205137e5
|
@ -129,6 +129,9 @@
|
|||
},
|
||||
"required": [ "email" ]
|
||||
},
|
||||
"RunOnServerStarted": { "type": "boolean", "default": null, "description": "Execute this when the server startup is completed. The first parameter will be the server version." },
|
||||
"RunOnServerUpdated": { "type": "boolean", "default": null, "description": "Execute this when the server has been updated. The first parameter will be the server version." },
|
||||
"RunOnServerError": { "type": "boolean", "default": null, "description": "Execute this when the server has to restart due to an error. The first parameter will be the server version." },
|
||||
"publicPushNotifications": { "type": "boolean", "default": false, "description": "When true, this server uses MeshCentral.com a push notification relay for Android notifications. Push notifications work even if the Android app is not open." },
|
||||
"desktopMultiplex": { "type": "boolean", "default": false, "description": "When true, enabled a server modules that efficiently splits a remote desktop stream to multiple browsers. Also allows slow browsers to not slow down the session for fast ones, this comes at the cost of extra server memory and processing for all remote desktop sessions." },
|
||||
"ipBlockedUserRedirect" : { "type": "string", "default": null, "description": "If set, a user from a banned IP address will be redirected to this URL." },
|
||||
|
|
|
@ -471,6 +471,15 @@ function CreateMeshCentralServer(config, args) {
|
|||
xxprocess.stderr.on('data', function (data) { xxprocess.data += data; });
|
||||
xxprocess.on('close', function (code) {
|
||||
if (code == 0) { console.log('Update completed...'); }
|
||||
|
||||
// Run the server updated script if present
|
||||
if (typeof obj.config.settings.runonserverupdated == 'string') {
|
||||
const child_process = require('child_process');
|
||||
var parentpath = __dirname;
|
||||
if ((__dirname.endsWith('/node_modules/meshcentral')) || (__dirname.endsWith('\\node_modules\\meshcentral')) || (__dirname.endsWith('/node_modules/meshcentral/')) || (__dirname.endsWith('\\node_modules\\meshcentral\\'))) { parentpath = require('path').join(__dirname, '../..'); }
|
||||
child_process.exec(obj.config.settings.runonserverupdated + ' ' + getCurrentVersion(), { maxBuffer: 512000, timeout: 120000, cwd: parentpath }, function (error, stdout, stderr) { });
|
||||
}
|
||||
|
||||
if (obj.args.cleannpmcacheonupdate === true) {
|
||||
// Perform NPM cache clean
|
||||
console.log('Cleaning NPM cache...');
|
||||
|
@ -487,6 +496,14 @@ function CreateMeshCentralServer(config, args) {
|
|||
console.log(error);
|
||||
console.log('ERROR: MeshCentral failed with critical error, check mesherrors.txt. Restarting in 5 seconds...');
|
||||
setTimeout(function () { obj.launchChildServer(startArgs); }, 5000);
|
||||
|
||||
// Run the server error script if present
|
||||
if (typeof obj.config.settings.runonservererror == 'string') {
|
||||
const child_process = require('child_process');
|
||||
var parentpath = __dirname;
|
||||
if ((__dirname.endsWith('/node_modules/meshcentral')) || (__dirname.endsWith('\\node_modules\\meshcentral')) || (__dirname.endsWith('/node_modules/meshcentral/')) || (__dirname.endsWith('\\node_modules\\meshcentral\\'))) { parentpath = require('path').join(__dirname, '../..'); }
|
||||
child_process.exec(obj.config.settings.runonservererror + ' ' + getCurrentVersion(), { maxBuffer: 512000, timeout: 120000, cwd: parentpath }, function (error, stdout, stderr) { });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1856,6 +1873,14 @@ function CreateMeshCentralServer(config, args) {
|
|||
var ipKvmSupport = false;
|
||||
for (var i in obj.config.domains) { if (obj.config.domains[i].ipkvm == true) { ipKvmSupport = true; } }
|
||||
if (ipKvmSupport) { obj.ipKvmManager = require('./meshipkvm').CreateIPKVMManager(obj); }
|
||||
|
||||
// Run the server start script if present
|
||||
if (typeof obj.config.settings.runonserverstarted == 'string') {
|
||||
const child_process = require('child_process');
|
||||
var parentpath = __dirname;
|
||||
if ((__dirname.endsWith('/node_modules/meshcentral')) || (__dirname.endsWith('\\node_modules\\meshcentral')) || (__dirname.endsWith('/node_modules/meshcentral/')) || (__dirname.endsWith('\\node_modules\\meshcentral\\'))) { parentpath = require('path').join(__dirname, '../..'); }
|
||||
child_process.exec(obj.config.settings.runonserverstarted + ' ' + getCurrentVersion(), { maxBuffer: 512000, timeout: 120000, cwd: parentpath }, function (error, stdout, stderr) { });
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh any certificate hashs from the reverse proxy
|
||||
|
@ -3334,7 +3359,7 @@ function InstallModules(modules, func) {
|
|||
// Check if a module is present and install it if missing
|
||||
function InstallModule(modulename, func, tag1, tag2) {
|
||||
console.log('Installing ' + modulename + '...');
|
||||
var child_process = require('child_process');
|
||||
const child_process = require('child_process');
|
||||
var parentpath = __dirname;
|
||||
|
||||
// Get the working directory
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
"_mpsAliasHost": "mps.mydomain.com",
|
||||
"_mpsTlsOffload": true,
|
||||
"_no2FactorAuth": true,
|
||||
"_runOnServerStarted": "c:\\tmp\\mcstart.bat",
|
||||
"_runOnServerUpdated": "c:\\tmp\\mcupdate.bat",
|
||||
"_runOnServerError": "c:\\tmp\\mcerror.bat",
|
||||
"_log": "main,web,webrequest,cert",
|
||||
"_syslog": "meshcentral",
|
||||
"_syslogauth": "meshcentral-auth",
|
||||
|
|
Loading…
Reference in New Issue