mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-19 01:35:28 +01:00
Merge branch 'pretzel-fix' into 'dev'
Pretzel fix See merge request crafty-controller/crafty-commander!111
This commit is contained in:
commit
b6cf8390ad
@ -5,6 +5,8 @@ import time
|
|||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from app.classes.shared.tasks import TasksManager
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
from app.classes.shared.console import console
|
from app.classes.shared.console import console
|
||||||
@ -35,6 +37,7 @@ class MainPrompt(cmd.Cmd, object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def do_exit(self, line):
|
def do_exit(self, line):
|
||||||
|
self.tasks_manager._main_graceful_exit()
|
||||||
self.universal_exit()
|
self.universal_exit()
|
||||||
|
|
||||||
def do_migrations(self, line):
|
def do_migrations(self, line):
|
||||||
|
@ -168,6 +168,7 @@ class Controller:
|
|||||||
return running_servers
|
return running_servers
|
||||||
|
|
||||||
def stop_all_servers(self):
|
def stop_all_servers(self):
|
||||||
|
print("in stop all servers")
|
||||||
servers = self.list_running_servers()
|
servers = self.list_running_servers()
|
||||||
logger.info("Found {} running server(s)".format(len(servers)))
|
logger.info("Found {} running server(s)".format(len(servers)))
|
||||||
console.info("Found {} running server(s)".format(len(servers)))
|
console.info("Found {} running server(s)".format(len(servers)))
|
||||||
@ -175,7 +176,10 @@ class Controller:
|
|||||||
logger.info("Stopping All Servers")
|
logger.info("Stopping All Servers")
|
||||||
console.info("Stopping All Servers")
|
console.info("Stopping All Servers")
|
||||||
|
|
||||||
|
print(servers)
|
||||||
|
|
||||||
for s in servers:
|
for s in servers:
|
||||||
|
print(s)
|
||||||
logger.info("Stopping Server ID {} - {}".format(s['id'], s['name']))
|
logger.info("Stopping Server ID {} - {}".format(s['id'], s['name']))
|
||||||
console.info("Stopping Server ID {} - {}".format(s['id'], s['name']))
|
console.info("Stopping Server ID {} - {}".format(s['id'], s['name']))
|
||||||
|
|
||||||
|
@ -257,20 +257,6 @@ class Server:
|
|||||||
'error': translation.translate('error', 'start-error', user_lang).format(self.name, ex)
|
'error': translation.translate('error', 'start-error', user_lang).format(self.name, ex)
|
||||||
})
|
})
|
||||||
return False
|
return False
|
||||||
if user_id:
|
|
||||||
if helper.check_internet():
|
|
||||||
loc_server_port = servers_helper.get_server_stats_by_id(self.server_id)['server_port']
|
|
||||||
if helper.check_port(loc_server_port):
|
|
||||||
websocket_helper.broadcast_user(user_id, 'send_start_reload', {
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
websocket_helper.broadcast_user(user_id, 'send_start_error', {
|
|
||||||
'error': translation.translate('error', 'closedPort', user_lang).format(loc_server_port)
|
|
||||||
})
|
|
||||||
else:
|
|
||||||
websocket_helper.broadcast_user(user_id, 'send_start_error', {
|
|
||||||
'error': translation.translate('error', 'internet', user_lang)
|
|
||||||
})
|
|
||||||
servers_helper.set_waiting_start(self.server_id, False)
|
servers_helper.set_waiting_start(self.server_id, False)
|
||||||
out_buf = ServerOutBuf(self.process, self.server_id)
|
out_buf = ServerOutBuf(self.process, self.server_id)
|
||||||
|
|
||||||
@ -295,6 +281,20 @@ class Server:
|
|||||||
console.info("Server {} has crash detection enabled - starting watcher task".format(self.name))
|
console.info("Server {} has crash detection enabled - starting watcher task".format(self.name))
|
||||||
|
|
||||||
self.crash_watcher_schedule = schedule.every(30).seconds.do(self.detect_crash).tag(self.name)
|
self.crash_watcher_schedule = schedule.every(30).seconds.do(self.detect_crash).tag(self.name)
|
||||||
|
if user_id:
|
||||||
|
if helper.check_internet():
|
||||||
|
loc_server_port = servers_helper.get_server_stats_by_id(self.server_id)['server_port']
|
||||||
|
if helper.check_port(loc_server_port):
|
||||||
|
websocket_helper.broadcast_user(user_id, 'send_start_reload', {
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
websocket_helper.broadcast_user(user_id, 'send_start_error', {
|
||||||
|
'error': translation.translate('error', 'closedPort', user_lang).format(loc_server_port)
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
websocket_helper.broadcast_user(user_id, 'send_start_error', {
|
||||||
|
'error': translation.translate('error', 'internet', user_lang)
|
||||||
|
})
|
||||||
|
|
||||||
def stop_threaded_server(self):
|
def stop_threaded_server(self):
|
||||||
self.stop_server()
|
self.stop_server()
|
||||||
|
@ -109,7 +109,9 @@ class TasksManager:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
def _main_graceful_exit(self):
|
def _main_graceful_exit(self):
|
||||||
|
print("in graceful")
|
||||||
try:
|
try:
|
||||||
|
print("in try")
|
||||||
os.remove(helper.session_file)
|
os.remove(helper.session_file)
|
||||||
os.remove(os.path.join(helper.root_dir, '.header'))
|
os.remove(os.path.join(helper.root_dir, '.header'))
|
||||||
self.controller.stop_all_servers()
|
self.controller.stop_all_servers()
|
||||||
|
4
main.py
4
main.py
@ -152,6 +152,7 @@ if __name__ == '__main__':
|
|||||||
print() # for newline
|
print() # for newline
|
||||||
logger.info("Recieved SIGTERM, stopping Crafty")
|
logger.info("Recieved SIGTERM, stopping Crafty")
|
||||||
console.info("Recieved SIGTERM, stopping Crafty")
|
console.info("Recieved SIGTERM, stopping Crafty")
|
||||||
|
tasks_manager._main_graceful_exit()
|
||||||
Crafty.universal_exit()
|
Crafty.universal_exit()
|
||||||
|
|
||||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||||
@ -163,6 +164,7 @@ if __name__ == '__main__':
|
|||||||
print() # for newline
|
print() # for newline
|
||||||
logger.info("Recieved SIGINT, stopping Crafty")
|
logger.info("Recieved SIGINT, stopping Crafty")
|
||||||
console.info("Recieved SIGINT, stopping Crafty")
|
console.info("Recieved SIGINT, stopping Crafty")
|
||||||
|
tasks_manager._main_graceful_exit()
|
||||||
Crafty.universal_exit()
|
Crafty.universal_exit()
|
||||||
else:
|
else:
|
||||||
print("Crafty started in daemon mode, no shell will be printed")
|
print("Crafty started in daemon mode, no shell will be printed")
|
||||||
@ -175,5 +177,5 @@ if __name__ == '__main__':
|
|||||||
logger.info("Recieved SIGINT, stopping Crafty")
|
logger.info("Recieved SIGINT, stopping Crafty")
|
||||||
console.info("Recieved SIGINT, stopping Crafty")
|
console.info("Recieved SIGINT, stopping Crafty")
|
||||||
break
|
break
|
||||||
|
tasks_manager._main_graceful_exit()
|
||||||
Crafty.universal_exit()
|
Crafty.universal_exit()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user