mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fixed errand print statement
Re-init all servers when adding a server server builder tested well. Next is importing a server
This commit is contained in:
parent
6ec2f1c6ac
commit
a0fcda018c
@ -8,6 +8,7 @@ from datetime import datetime
|
||||
from app.classes.shared.helpers import helper
|
||||
from app.classes.shared.console import console
|
||||
from app.classes.shared.models import Servers
|
||||
from app.classes.minecraft.controller import controller
|
||||
from app.classes.minecraft.server_props import ServerProps
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -180,15 +181,16 @@ class ServerJars:
|
||||
Servers.auto_start: False,
|
||||
Servers.auto_start_delay: 10,
|
||||
Servers.crash_detection: False,
|
||||
Servers.log_path:"{}/logs/latest.log".format(server_dir),
|
||||
Servers.stop_command:'stop'
|
||||
|
||||
Servers.log_path: "{}/logs/latest.log".format(server_dir),
|
||||
Servers.stop_command: 'stop'
|
||||
}).execute()
|
||||
|
||||
|
||||
try:
|
||||
# place a file in the dir saying it's owned by crafty
|
||||
with open(os.path.join(server_dir, "crafty_managed.txt"), 'w') as f:
|
||||
f.write("The server in this directory is managed by Crafty Controller.\n Leave this file alone please")
|
||||
f.write("The server in this directory is managed by Crafty Controller.\n Leave this directory/files alone please")
|
||||
f.close()
|
||||
|
||||
# do a eula.txt
|
||||
@ -205,6 +207,9 @@ class ServerJars:
|
||||
logger.error("Unable to create required server files due to :{}".format(e))
|
||||
return False
|
||||
|
||||
# let's re-init all servers
|
||||
controller.init_all_servers()
|
||||
|
||||
return True
|
||||
|
||||
server_jar_obj = ServerJars()
|
||||
|
@ -178,7 +178,7 @@ class Stats:
|
||||
internal_ip = server_data.get('server_ip', "127.0.0.1")
|
||||
server_port = server_settings.get('server_port', "25565")
|
||||
|
||||
logger.debug("Pinging %s on port %s", internal_ip, server_port)
|
||||
logger.debug("Pinging {} on port {}".format(internal_ip, server_port))
|
||||
int_mc_ping = ping(internal_ip, int(server_port))
|
||||
|
||||
int_data = "Unable to connect"
|
||||
@ -194,7 +194,7 @@ class Stats:
|
||||
'mem': p_stats.get('memory_usage', '0'),
|
||||
'world_name': world_name,
|
||||
'world_size': self.get_world_size(world_path),
|
||||
'server_port': s['server_settings']['server-port'],
|
||||
'server_port': server_port,
|
||||
'int_ping_results': int_data
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,8 @@ class Servers(BaseModel):
|
||||
auto_start_delay = IntegerField(default=10)
|
||||
crash_detection = BooleanField(default=0)
|
||||
stop_command = CharField(default="stop")
|
||||
server_port = IntegerField(default=25565)
|
||||
|
||||
|
||||
class Meta:
|
||||
table_name = "servers"
|
||||
|
@ -89,6 +89,10 @@ class TasksManager:
|
||||
stats_update_frequency = int(helper.get_setting("CRAFTY", 'stats_update_frequency'))
|
||||
logger.info("Stats collection frequency set to {stats} seconds".format(stats=stats_update_frequency))
|
||||
console.info("Stats collection frequency set to {stats} seconds".format(stats=stats_update_frequency))
|
||||
# one for now,
|
||||
stats.record_stats()
|
||||
|
||||
# one for later
|
||||
schedule.every(stats_update_frequency).seconds.do(stats.record_stats)
|
||||
|
||||
@staticmethod
|
||||
|
@ -9,7 +9,6 @@ class DefaultHandler(BaseHandler):
|
||||
|
||||
# Override prepare() instead of get() to cover all possible HTTP methods.
|
||||
def prepare(self, page=None):
|
||||
print(page)
|
||||
if page is not None:
|
||||
self.set_status(404)
|
||||
self.render("public/404.html")
|
||||
|
@ -35,12 +35,12 @@ class PanelHandler(BaseHandler):
|
||||
'hosts_data': db_helper.get_latest_hosts_stats()
|
||||
|
||||
}
|
||||
# print(page_data['hosts_data'])
|
||||
|
||||
# if no servers defined, let's go to the build server area
|
||||
if page_data['server_stats']['total'] == 0:
|
||||
self.set_status(301)
|
||||
self.redirect("/server/step1")
|
||||
return False
|
||||
|
||||
if page == 'unauthorized':
|
||||
template = "panel/denied.html"
|
||||
|
@ -65,8 +65,6 @@ class ServerHandler(BaseHandler):
|
||||
'user_data': user_data,
|
||||
}
|
||||
|
||||
print(page)
|
||||
|
||||
if page == "step1":
|
||||
|
||||
server = bleach.clean(self.get_argument('server', ''))
|
||||
|
10
main.py
10
main.py
@ -86,6 +86,11 @@ if __name__ == '__main__':
|
||||
# slowing down reporting just for a 1/2 second so messages look cleaner
|
||||
time.sleep(.5)
|
||||
|
||||
# do our installer stuff
|
||||
if installer.is_fresh_install():
|
||||
installer.create_tables()
|
||||
installer.default_settings()
|
||||
|
||||
# start stats logging
|
||||
tasks_manager.start_stats_recording()
|
||||
|
||||
@ -95,11 +100,6 @@ if __name__ == '__main__':
|
||||
# this should always be last
|
||||
tasks_manager.start_main_kill_switch_watcher()
|
||||
|
||||
# do our installer stuff
|
||||
if installer.is_fresh_install():
|
||||
installer.create_tables()
|
||||
installer.default_settings()
|
||||
|
||||
# init servers
|
||||
logger.info("Initializing all servers defined")
|
||||
console.info("Initializing all servers defined")
|
||||
|
Loading…
Reference in New Issue
Block a user