This is the unstable version of pretzel where he breaks things.

This commit is contained in:
Andrew 2021-08-07 13:15:53 -04:00
parent ca9788081b
commit e86998e57d
3 changed files with 69 additions and 1 deletions

View File

@ -140,7 +140,11 @@ class Server:
try:
self.process = pexpect.spawn(self.server_command, cwd=self.server_path, timeout=None, encoding=None)
except Exception as ex:
logger.error("Server {} failed to start with error code: {}".format(self.name, ex))
msg = "Server {} failed to start with error code: {}".format(self.name, ex)
logger.error(msg)
websocket_helper.broadcast('send_start_error', {
'error': msg
})
return False
self.is_crashed = False

View File

@ -235,6 +235,39 @@ function send_command (server_id, command){
});
}
if (webSocket) {
webSocket.on('send_start_error', function (start_error) {
var closeEl = document.createElement('span');
var strongEL = document.createElement('strong');
var msgEl = document.createElement('div');
closeEl.innerHTML = '×';
strongEL.textContent = 'Warning: ';
msgEl.append(strongEL, start_error.error);
closeEl.style.marginLeft = '15px';
closeEl.style.fontWeight = 'bold';
closeEl.style.float = 'right';
closeEl.style.fontSize = '22px';
closeEl.style.lineHeight = '20px';
closeEl.style.cursor = 'pointer';
closeEl.addEventListener('click', function () {this.parentElement.style.display='none';});
var parentEl = document.createElement('div');
parentEl.style.padding = '20px';
parentEl.style.backgroundColor = '#f7970f';
parentEl.appendChild(closeEl);
parentEl.appendChild(msgEl);
document.querySelector('.warnings').appendChild(parentEl);
});
}
$( document ).ready(function() {
console.log('ready for JS!')

View File

@ -144,7 +144,38 @@
}
});
}
if (webSocket) {
webSocket.on('send_start_error', function (start_error) {
var closeEl = document.createElement('span');
var strongEL = document.createElement('strong');
var msgEl = document.createElement('div');
closeEl.innerHTML = '×';
strongEL.textContent = 'Warning: ';
msgEl.append(strongEL, start_error.error);
closeEl.style.marginLeft = '15px';
closeEl.style.fontWeight = 'bold';
closeEl.style.float = 'right';
closeEl.style.fontSize = '22px';
closeEl.style.lineHeight = '20px';
closeEl.style.cursor = 'pointer';
closeEl.addEventListener('click', function () {this.parentElement.style.display='none';});
var parentEl = document.createElement('div');
parentEl.style.padding = '20px';
parentEl.style.backgroundColor = '#f7970f';
parentEl.appendChild(closeEl);
parentEl.appendChild(msgEl);
document.querySelector('.warnings').appendChild(parentEl);
});
}
// Convert running to lower case (example: 'True' converts to 'true') and
// then to boolean via JSON.parse()
let online = JSON.parse('{{ data['server_stats']['running'] }}'.toLowerCase());