mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix bug where terminal will not exit
This commit is contained in:
parent
635f671fd9
commit
8999a9a5c3
@ -5,6 +5,8 @@ import time
|
||||
import threading
|
||||
import logging
|
||||
|
||||
from app.classes.shared.tasks import TasksManager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from app.classes.shared.console import console
|
||||
@ -35,6 +37,7 @@ class MainPrompt(cmd.Cmd, object):
|
||||
pass
|
||||
|
||||
def do_exit(self, line):
|
||||
self.tasks_manager._main_graceful_exit()
|
||||
self.universal_exit()
|
||||
|
||||
def do_migrations(self, line):
|
||||
|
@ -168,6 +168,7 @@ class Controller:
|
||||
return running_servers
|
||||
|
||||
def stop_all_servers(self):
|
||||
print("in stop all servers")
|
||||
servers = self.list_running_servers()
|
||||
logger.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")
|
||||
console.info("Stopping All Servers")
|
||||
|
||||
print(servers)
|
||||
|
||||
for s in servers:
|
||||
print(s)
|
||||
logger.info("Stopping Server ID {} - {}".format(s['id'], s['name']))
|
||||
console.info("Stopping Server ID {} - {}".format(s['id'], s['name']))
|
||||
|
||||
|
@ -109,7 +109,9 @@ class TasksManager:
|
||||
time.sleep(1)
|
||||
|
||||
def _main_graceful_exit(self):
|
||||
print("in graceful")
|
||||
try:
|
||||
print("in try")
|
||||
os.remove(helper.session_file)
|
||||
os.remove(os.path.join(helper.root_dir, '.header'))
|
||||
self.controller.stop_all_servers()
|
||||
|
4
main.py
4
main.py
@ -152,6 +152,7 @@ if __name__ == '__main__':
|
||||
print() # for newline
|
||||
logger.info("Recieved SIGTERM, stopping Crafty")
|
||||
console.info("Recieved SIGTERM, stopping Crafty")
|
||||
tasks_manager._main_graceful_exit()
|
||||
Crafty.universal_exit()
|
||||
|
||||
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||
@ -163,6 +164,7 @@ if __name__ == '__main__':
|
||||
print() # for newline
|
||||
logger.info("Recieved SIGINT, stopping Crafty")
|
||||
console.info("Recieved SIGINT, stopping Crafty")
|
||||
tasks_manager._main_graceful_exit()
|
||||
Crafty.universal_exit()
|
||||
else:
|
||||
print("Crafty started in daemon mode, no shell will be printed")
|
||||
@ -175,5 +177,5 @@ if __name__ == '__main__':
|
||||
logger.info("Recieved SIGINT, stopping Crafty")
|
||||
console.info("Recieved SIGINT, stopping Crafty")
|
||||
break
|
||||
|
||||
tasks_manager._main_graceful_exit()
|
||||
Crafty.universal_exit()
|
||||
|
Loading…
Reference in New Issue
Block a user