work on server shutdown..

This commit is contained in:
DJ2LS 2024-05-13 11:41:06 +02:00
parent 5152161649
commit fa6e591ca9
2 changed files with 15 additions and 8 deletions

View file

@ -7,6 +7,8 @@ from message_system_db_messages import DatabaseManagerMessages
from message_system_db_beacon import DatabaseManagerBeacon from message_system_db_beacon import DatabaseManagerBeacon
import explorer import explorer
import command_beacon import command_beacon
import atexit
class ScheduleManager: class ScheduleManager:
@ -39,7 +41,7 @@ class ScheduleManager:
"""Start scheduling events and run the scheduler in a separate thread.""" """Start scheduling events and run the scheduler in a separate thread."""
# wait some time # wait some time
threading.Event().wait(timeout=10) #threading.Event().wait(timeout=10)
# get actual freedata_server instance # get actual freedata_server instance
self.modem = modem self.modem = modem

View file

@ -26,6 +26,7 @@ import command_arq_raw
import command_message_send import command_message_send
import event_manager import event_manager
import atexit import atexit
import threading
from message_system_db_manager import DatabaseManager from message_system_db_manager import DatabaseManager
from message_system_db_messages import DatabaseManagerMessages from message_system_db_messages import DatabaseManagerMessages
@ -345,14 +346,17 @@ def sock_states(sock):
def stop_server(): def stop_server():
print("------------------------------------------") print("------------------------------------------")
# TODO This is causing problems for some reasons. # TODO This is causing problems for some reasons.
#if "service_manager" : if hasattr(app, 'service_manager'):
# app.service_manager.modem_service.put("stop") if hasattr(app, 'socket_interface_manager') and app.socket_interface_manager:
# if app.socket_interface_manager: app.socket_interface_manager.stop_servers()
# app.socket_interface_manager.stop_servers()
# if app.service_manager.modem: if hasattr(app.service_manager, 'modem_service') and app.service_manager.modem_service:
# app.service_manager.modem.sd_input_stream.stop app.service_manager.modem_service.put("stop")
#time.sleep(1)
if hasattr(app.service_manager, 'modem') and app.service_manager.modem:
app.service_manager.modem.sd_input_stream.stop
threading.Event().wait(2)
def main(): def main():
app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 10} app.config['SOCK_SERVER_OPTIONS'] = {'ping_interval': 10}
@ -395,5 +399,6 @@ def main():
app.run(modemaddress, modemport, debug=False) app.run(modemaddress, modemport, debug=False)
if __name__ == "__main__": if __name__ == "__main__":
main() main()