mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix start server after updates
Fix update notifs
This commit is contained in:
parent
1ca34948cc
commit
76a499f5a4
@ -1042,6 +1042,7 @@ class ServerInstance:
|
||||
return self.stats_helper.get_server_stats()["updating"]
|
||||
|
||||
def a_jar_update(self):
|
||||
server_users = PermissionsServers.get_server_user_list(self.server_id)
|
||||
was_started = "-1"
|
||||
self.backup_server()
|
||||
# checks if server is running. Calls shutdown if it is running.
|
||||
@ -1060,8 +1061,10 @@ class ServerInstance:
|
||||
message = (
|
||||
'<a data-id="' + str(self.server_id) + '" class=""> UPDATING...</i></a>'
|
||||
)
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
for user in server_users:
|
||||
self.helper.websocket_helper.broadcast_user_page(
|
||||
"/panel/server_detail",
|
||||
user,
|
||||
"update_button_status",
|
||||
{
|
||||
"isUpdating": self.check_update(),
|
||||
@ -1070,9 +1073,6 @@ class ServerInstance:
|
||||
"string": message,
|
||||
},
|
||||
)
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/dashboard", "send_start_reload", {}
|
||||
)
|
||||
backup_dir = os.path.join(
|
||||
Helpers.get_os_understandable_path(self.settings["path"]),
|
||||
"crafty_executable_backups",
|
||||
@ -1114,7 +1114,6 @@ class ServerInstance:
|
||||
|
||||
# check if backup was successful
|
||||
if self.last_backup_failed:
|
||||
server_users = PermissionsServers.get_server_user_list(self.server_id)
|
||||
for user in server_users:
|
||||
self.helper.websocket_helper.broadcast_user(
|
||||
user,
|
||||
@ -1164,7 +1163,6 @@ class ServerInstance:
|
||||
if len(self.helper.websocket_helper.clients) > 0:
|
||||
# There are clients
|
||||
self.check_update()
|
||||
server_users = PermissionsServers.get_server_user_list(self.server_id)
|
||||
for user in server_users:
|
||||
self.helper.websocket_helper.broadcast_user(
|
||||
user,
|
||||
@ -1173,8 +1171,10 @@ class ServerInstance:
|
||||
)
|
||||
# sleep so first notif can completely run
|
||||
time.sleep(3)
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
for user in server_users:
|
||||
self.helper.websocket_helper.broadcast_user_page(
|
||||
"/panel/server_detail",
|
||||
user,
|
||||
"update_button_status",
|
||||
{
|
||||
"isUpdating": self.check_update(),
|
||||
@ -1182,14 +1182,9 @@ class ServerInstance:
|
||||
"wasRunning": was_started,
|
||||
},
|
||||
)
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/dashboard", "send_start_reload", {}
|
||||
self.helper.websocket_helper.broadcast_user_page(
|
||||
user, "/panel/dashboard", "send_start_reload", {}
|
||||
)
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/server_detail", "remove_spinner", {}
|
||||
)
|
||||
server_users = PermissionsServers.get_server_user_list(self.server_id)
|
||||
for user in server_users:
|
||||
self.helper.websocket_helper.broadcast_user(
|
||||
user,
|
||||
"notification",
|
||||
@ -1204,9 +1199,8 @@ class ServerInstance:
|
||||
self.settings["server_ip"],
|
||||
)
|
||||
if was_started:
|
||||
self.start_server()
|
||||
self.start_server(HelperUsers.get_user_id_by_name("system"))
|
||||
else:
|
||||
server_users = PermissionsServers.get_server_user_list(self.server_id)
|
||||
for user in server_users:
|
||||
self.helper.websocket_helper.broadcast_user(
|
||||
user,
|
||||
@ -1217,6 +1211,8 @@ class ServerInstance:
|
||||
)
|
||||
logger.error("Executable download failed.")
|
||||
self.stats_helper.set_update(False)
|
||||
for user in server_users:
|
||||
self.helper.websocket_helper.broadcast_user(user, "remove_spinner", {})
|
||||
|
||||
# **********************************************************************************
|
||||
# Minecraft Servers Statistics
|
||||
|
@ -250,18 +250,16 @@
|
||||
</div>
|
||||
<div class="text-center">
|
||||
{% if data['server_stats']['running'] %}
|
||||
<button onclick="send_command(serverId, 'update_executable');" id="update_executable"
|
||||
style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
||||
'update', data['lang']) }}</button>
|
||||
{% if data['server_stats']['updating'] %}
|
||||
<button onclick="send_command(serverId, 'update_executable');" id="update_executable"
|
||||
style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
||||
'update', data['lang']) }} <i id="update-spinner" class="fa fa-spinner fa-spin"></i></button>
|
||||
<i id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
||||
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
||||
class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
||||
'update', data['lang']) }}</button>
|
||||
{% else %}
|
||||
<button onclick="send_command(serverId, 'update_executable');" id="update_executable"
|
||||
style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
||||
'update', data['lang']) }} <i style="visibility: hidden;" id="update-spinner"
|
||||
class="fa fa-spinner fa-spin"></i></button>
|
||||
<i style="visibility: hidden;" id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
||||
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
||||
class="btn btn-warning m-1 flex-grow-1 disabled">{{ translate('serverConfig',
|
||||
'update', data['lang']) }}</button>
|
||||
{% end %}
|
||||
<a class="btn btn-sm btn-danger disabled">{{ translate('serverConfig', 'deleteServer', data['lang'])
|
||||
}}</a><br />
|
||||
@ -269,14 +267,15 @@
|
||||
{% else %}
|
||||
{% if not data['failed'] %}
|
||||
{% if data['server_stats']['updating'] %}
|
||||
<button onclick="send_command(serverId, 'update_executable');" id="update_executable"
|
||||
style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig',
|
||||
'update', data['lang']) }} <i id="update-spinner" class="fa fa-spinner fa-spin"></i></button>
|
||||
<i id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
||||
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
||||
class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig',
|
||||
'update', data['lang']) }}</button>
|
||||
{% else %}
|
||||
<button onclick="send_command(serverId, 'update_executable');" id="update_executable"
|
||||
style="max-width: 7rem;" class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig',
|
||||
'update', data['lang']) }} <i style="visibility: hidden;" id="update-spinner"
|
||||
class="fa fa-spinner fa-spin"></i></button>
|
||||
<i style="visibility: hidden;" id="update-spinner" class="fa fa-spinner fa-spin"></i> <button
|
||||
onclick="send_command(serverId, 'update_executable');" id="update_executable" style="max-width: 7rem;"
|
||||
class="btn btn-warning m-1 flex-grow-1">{{ translate('serverConfig',
|
||||
'update', data['lang']) }}</button>
|
||||
{% end %}
|
||||
{% end %}
|
||||
{% if not data['failed'] %}
|
||||
@ -384,16 +383,11 @@
|
||||
success: function (data) {
|
||||
console.log("got response:");
|
||||
console.log(data);
|
||||
setTimeout(function () { location.reload(); }, 10000);
|
||||
if (command != "update_executable") {
|
||||
setTimeout(function () { location.reload(); }, 10000);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (command != "delete_server" && command != "delete_server_files") {
|
||||
bootbox.alert({
|
||||
backdrop: true,
|
||||
title: '{% raw translate("serverConfig", "sendingRequest", data['lang']) %}',
|
||||
message: '<div align="center"><i class="fas fa-spin fa-spinner"></i> {% raw translate("serverConfig", "bePatientUpdate", data['lang']) %} </div>'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteServer() {
|
||||
|
Loading…
Reference in New Issue
Block a user