added float_to_string for server memory configs

This commit is contained in:
Phillip 2021-01-19 09:17:29 -05:00
parent 19e4a31bf7
commit 9fb80a5062
2 changed files with 13 additions and 3 deletions

View File

@ -212,7 +212,9 @@ class Controller:
logger.error("Unable to create required server files due to :{}".format(e)) logger.error("Unable to create required server files due to :{}".format(e))
return False return False
server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(float(min_mem) * 1000, float(max_mem) * 1000, full_jar_path) 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)
server_log_file = "{}/logs/latest.log".format(server_dir) server_log_file = "{}/logs/latest.log".format(server_dir)
server_stop = "stop" server_stop = "stop"
@ -245,7 +247,9 @@ class Controller:
dir_util.copy_tree(server_path, new_server_dir) dir_util.copy_tree(server_path, new_server_dir)
full_jar_path = os.path.join(new_server_dir, server_jar) full_jar_path = os.path.join(new_server_dir, server_jar)
server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(float(min_mem) * 1000, float(max_mem) * 1000, full_jar_path) 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)
server_log_file = "{}/logs/latest.log".format(new_server_dir) server_log_file = "{}/logs/latest.log".format(new_server_dir)
server_stop = "stop" server_stop = "stop"
@ -264,7 +268,9 @@ class Controller:
return "false" return "false"
full_jar_path = os.path.join(new_server_dir, server_jar) full_jar_path = os.path.join(new_server_dir, server_jar)
server_command = 'java -Xms{}M -Xmx{}M -jar {} nogui'.format(float(min_mem) * 1000, float(max_mem) * 1000, full_jar_path) 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)
print('command: ' + server_command) print('command: ' + server_command)
server_log_file = "{}/logs/latest.log".format(new_server_dir) server_log_file = "{}/logs/latest.log".format(new_server_dir)
server_stop = "stop" server_stop = "stop"

View File

@ -46,6 +46,10 @@ class Helpers:
self.passhasher = PasswordHasher() self.passhasher = PasswordHasher()
self.exiting = False self.exiting = False
def float_to_string(self, gbs: int):
s = str(float(gbs) * 1000).rstrip("0").rstrip(".")
return s
def check_file_perms(self, path): def check_file_perms(self, path):
try: try:
fp = open(path, "r").close() fp = open(path, "r").close()