From 859f904602081a22d8b6f1228502053decb921c2 Mon Sep 17 00:00:00 2001 From: Hemna Date: Wed, 23 Aug 2023 13:45:46 -0400 Subject: [PATCH] Start keepalive thread first This patch changes the order of the threads starting. The Keepalive thread's job is to test the aprsis/kiss client to see if it's up and running, and then issue a reset if it's down. On SIGINT, the keepalive might issue that reset in the middle of a shutdown, which might cause things to hang when everything should be shutting down. Making the KeepaliveThread first, means it will be the first to be shut down as well, preventing the next loop from resetting the client. --- aprsd/cmds/server.py | 6 +++--- aprsd/cmds/webchat.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/aprsd/cmds/server.py b/aprsd/cmds/server.py index af8f797..886d6b9 100644 --- a/aprsd/cmds/server.py +++ b/aprsd/cmds/server.py @@ -94,6 +94,9 @@ def server(ctx, flush): packets.WatchList().load() packets.SeenList().load() + keepalive = threads.KeepAliveThread() + keepalive.start() + rx_thread = rx.APRSDPluginRXThread( packet_queue=threads.packet_queue, ) @@ -105,9 +108,6 @@ def server(ctx, flush): packets.PacketTrack().restart() - keepalive = threads.KeepAliveThread() - keepalive.start() - if CONF.rpc_settings.enabled: rpc = rpc_server.APRSDRPCThread() rpc.start() diff --git a/aprsd/cmds/webchat.py b/aprsd/cmds/webchat.py index 67ae9cb..42d74c0 100644 --- a/aprsd/cmds/webchat.py +++ b/aprsd/cmds/webchat.py @@ -479,6 +479,10 @@ def webchat(ctx, flush, port): packets.WatchList() packets.SeenList() + keepalive = threads.KeepAliveThread() + LOG.info("Start KeepAliveThread") + keepalive.start() + socketio = init_flask(loglevel, quiet) rx_thread = rx.APRSDPluginRXThread( packet_queue=threads.packet_queue, @@ -490,9 +494,6 @@ def webchat(ctx, flush, port): ) process_thread.start() - keepalive = threads.KeepAliveThread() - LOG.info("Start KeepAliveThread") - keepalive.start() LOG.info("Start socketio.run()") socketio.run( flask_app,