diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 7dc4c892..5403dbbb 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -175,7 +175,7 @@ class Controller: tempZipStorage += '.zip' websocket_helper.broadcast_user(exec_user['user_id'], 'send_logs_bootbox', { }) - + self.users.set_support_path(exec_user['user_id'], tempZipStorage) @staticmethod @@ -287,9 +287,9 @@ class Controller: return False if helper.is_os_windows(): - server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), + server_command = 'java -Xms{}M -Xmx{}M -jar "{}" nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), - '"'+full_jar_path+'"') + full_jar_path) else: server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(helper.float_to_string(min_mem), helper.float_to_string(max_mem), @@ -471,7 +471,7 @@ class Controller: if helper.check_path_exists(self.servers.get_server_data_by_id(server_id)['backup_path']): shutil.rmtree(helper.get_os_understandable_path(self.servers.get_server_data_by_id(server_id)['backup_path'])) - + #Cleanup scheduled tasks try: helpers_management.delete_scheduled_task_by_server(server_id) diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index d35379ea..810703d3 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -1,4 +1,5 @@ from datetime import timedelta +from http import server import os import sys import json @@ -80,7 +81,7 @@ class TasksManager: logger.info("Reload from DB called. Current enabled schedules: ") for item in jobs: logger.info("JOB: {}".format(item)) - + def command_watcher(self): while True: # select any commands waiting to be processed @@ -285,8 +286,7 @@ class TasksManager: logger.info("Scheduling Serverjars.com cache refresh service every 12 hours") self.scheduler.add_job(server_jar_obj.refresh_cache, 'interval', hours=12, id="serverjars") - @staticmethod - def realtime(): + def realtime(self): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) @@ -311,7 +311,69 @@ class TasksManager: 'mem_percent': host_stats.get('mem_percent'), 'mem_usage': host_stats.get('mem_usage') }) - time.sleep(4) + + servers = self.controller.servers_list + servers_ping = [] + for srv in servers: + server_data = srv.get('server_data_obj', False) + if server_data: + server_id = server_data.get('server_id', False) + srv['raw_ping_result'] = self.controller.stats.get_raw_server_stats(server_id) + if ("{}".format(srv['raw_ping_result'].get('icon')) == "b''"): + srv['raw_ping_result']['icon'] = False + + servers_ping.append({ + 'id': srv['raw_ping_result'].get('id'), + 'started': srv['raw_ping_result'].get('started'), + 'running': srv['raw_ping_result'].get('running'), + 'cpu': srv['raw_ping_result'].get('cpu'), + 'mem': srv['raw_ping_result'].get('mem'), + 'mem_percent': srv['raw_ping_result'].get('mem_percent'), + 'world_name': srv['raw_ping_result'].get('world_name'), + 'world_size': srv['raw_ping_result'].get('world_size'), + 'server_port': srv['raw_ping_result'].get('server_port'), + 'int_ping_results': srv['raw_ping_result'].get('int_ping_results'), + 'online': srv['raw_ping_result'].get('online'), + 'max': srv['raw_ping_result'].get('max'), + 'players': srv['raw_ping_result'].get('players'), + 'desc': srv['raw_ping_result'].get('desc'), + 'version': srv['raw_ping_result'].get('version'), + 'icon': srv['raw_ping_result'].get('icon') + }) + if (len(websocket_helper.clients) > 0): + websocket_helper.broadcast_page_params( + '/panel/server_detail', + { + 'id': str(server_id) + }, + 'update_server_details', + { + 'id': srv['raw_ping_result'].get('id'), + 'started': srv['raw_ping_result'].get('started'), + 'running': srv['raw_ping_result'].get('running'), + 'cpu': srv['raw_ping_result'].get('cpu'), + 'mem': srv['raw_ping_result'].get('mem'), + 'mem_percent': srv['raw_ping_result'].get('mem_percent'), + 'world_name': srv['raw_ping_result'].get('world_name'), + 'world_size': srv['raw_ping_result'].get('world_size'), + 'server_port': srv['raw_ping_result'].get('server_port'), + 'int_ping_results': srv['raw_ping_result'].get('int_ping_results'), + 'online': srv['raw_ping_result'].get('online'), + 'max': srv['raw_ping_result'].get('max'), + 'players': srv['raw_ping_result'].get('players'), + 'desc': srv['raw_ping_result'].get('desc'), + 'version': srv['raw_ping_result'].get('version'), + 'icon': srv['raw_ping_result'].get('icon') + } + ) + + if (len(servers_ping) > 0) & (len(websocket_helper.clients) > 0): + try: + websocket_helper.broadcast_page('/panel/dashboard', 'update_server_status', servers_ping) + websocket_helper.broadcast_page('/status', 'update_server_status', servers_ping) + except: + console.warning("Can't broadcast server status to websocket") + time.sleep(5) def log_watcher(self): self.controller.servers.check_for_old_logs() diff --git a/app/frontend/templates/base.html b/app/frontend/templates/base.html index ab6d5656..b70091b4 100644 --- a/app/frontend/templates/base.html +++ b/app/frontend/templates/base.html @@ -1,153 +1,162 @@ -
- - - - {% block meta %}{% end %} -
- Thank you for your interest in contributing to Aracdia Technology's Crafty Controller.
+ Thank you for your interest in contributing to Aracdia Technology's Crafty Controller.
We are always thinking of new ways for our community to contribute to this awesome project.
If you don't see
a contribution method that peaks your interest now please check back soon.
- {{ translate('dashboard', 'cpuUsage', data['lang']) }}: {{ data.get('hosts_data').get('cpu_usage') }} +
+ {{ translate('dashboard', 'cpuUsage', data['lang']) }}: {{ + data.get('hosts_data').get('cpu_usage') }}
-- {{ translate('dashboard', 'memUsage', data['lang']) }}: {{ data.get('hosts_data').get('mem_percent') }}% +
+ {{ translate('dashboard', 'memUsage', data['lang']) }}: {{ + data.get('hosts_data').get('mem_percent') }}%
{{ data['server_stats']['running'] }} {{ translate('dashboard', 'online', data['lang']).lower() }}
-{{ data['server_stats']['stopped'] }} {{ translate('dashboard', 'offline', data['lang']).lower() }}
+{{ data['server_stats']['running'] }} {{ translate('dashboard', 'online', + data['lang']).lower() }}
+{{ data['server_stats']['stopped'] }} {{ translate('dashboard', + 'offline', data['lang']).lower() }}
{% if server['user_command_permission'] %} - {% if server['stats']['running'] %} - - - - {% elif server['stats']['updating']%} - {{ translate('serverTerm', 'updating', data['lang']) }} - {% elif server['stats']['waiting_start']%} - {{ translate('dashboard', 'starting', data['lang']) }} - {% else %} - - - - {% end %} + {% if server['stats']['running'] %} + + + + + {% elif server['stats']['updating']%} + {{ translate('serverTerm', 'updating', + data['lang']) }} + {% elif server['stats']['waiting_start']%} + {{ translate('dashboard', 'starting', + data['lang']) }} + {% else %} + + + + {% end %} {% end %} | -
-
+
+ |
-
+ " role="progressbar" style="width: {{server['stats']['cpu']}}%" aria-valuenow="0"
+ aria-valuemin="0" aria-valuemax="100">
{{server['stats']['cpu']}}%
- |
+
+ |
-
+ " role="progressbar" style="width: {{server['stats']['mem_percent']}}%" aria-valuenow="0"
+ aria-valuemin="0" aria-valuemax="100">
{{server['stats']['mem_percent']}}% -
{% if server['stats']['mem'] == 0 %}
- 0 MB
+ 0 MB
{% else %}
- {{server['stats']['mem']}}
+ {{server['stats']['mem']}}
{% end %}
+ |
{{ server['stats']['world_name'] }} : {{ server['stats']['world_size'] }}
|
-
+ |
{% if server['stats']['int_ping_results'] %}
- {{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max', data['lang']) }} |
- + {{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max', + data['lang']) }} - {% if server['stats']['desc'] != 'False' %} - {{ server['stats']['desc'] }} - {% end %} + {% if server['stats']['desc'] != 'False' %} + {{ server['stats']['desc'] }} + {% end %} - {% if server['stats']['version'] != 'False' %} - {{ server['stats']['version'] }} - {% end %} + {% if server['stats']['version'] != 'False' %} + {{ server['stats']['version'] }} + {% end %} {% end %}
+ |
{% if server['stats']['running'] %}
- {{ translate('dashboard', 'online', data['lang']) }}
+ {{ translate('dashboard', 'online',
+ data['lang']) }}
{% else %}
- {{ translate('dashboard', 'offline', data['lang']) }}
+ {{ translate('dashboard', 'offline',
+ data['lang']) }}
{% end %}
|
|
+ | - {{ server['server_data']['server_name'] }} + {{ server['server_data']['server_name'] }} | - {% if server['stats']['int_ping_results'] != 'False' %} -
- {{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max', data['lang']) }} - |
-
- {% if server['stats']['desc'] != 'False' %}
- {% if server['raw_ping_result']['icon'] %}
-
- {% else %}
-
- {% end %}
- {{ server['stats']['desc'] }} - {% end %} - |
- - {% if server['stats']['version'] != 'False' %} - {{ server['stats']['version'] }} - {% end %} + {% if server['stats']['int_ping_results'] != 'False' %} + |
+ {{ server['stats']['online'] }} / {{ server['stats']['max'] }} {{ translate('dashboard', 'max',
+ data['lang']) }} |
+ + {% if server['stats']['desc'] != 'False' %} + {% if server['raw_ping_result']['icon'] %} + {% else %} - | - - Crafty can't get infos from this Server - | + {% end %} -
+ {{
+ server['stats']['desc'] }} + {% end %} + |
+ + {% if server['stats']['version'] != 'False' %} + {{ server['stats']['version'] }} + {% end %} + | + {% else %} ++ + | ++ Crafty can't get infos from this Server + | ++ + | + {% end %} +{% if server['stats']['running'] %} - {{ translate('dashboard', 'online', data['lang']) }} + {{ translate('dashboard', 'online', data['lang']) + }} {% else %} - {{ translate('dashboard', 'offline', data['lang']) }} + {{ translate('dashboard', 'offline', data['lang']) + }} {% end %} |