mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-17 13:51:54 -05:00
Changed default log level to INFO
Also adjusted some of the logging for main, messaging and threads to be more sane
This commit is contained in:
parent
e7dc537900
commit
0aa905ebba
@ -32,7 +32,7 @@ import time
|
||||
|
||||
# local imports here
|
||||
import aprsd
|
||||
from aprsd import client, email, messaging, plugin, threads, utils
|
||||
from aprsd import client, email, flask, messaging, plugin, threads, utils
|
||||
import aprslib
|
||||
from aprslib.exceptions import LoginError
|
||||
import click
|
||||
@ -150,7 +150,7 @@ def install(append, case_insensitive, shell, path):
|
||||
click.echo("{} completion installed in {}".format(shell, path))
|
||||
|
||||
|
||||
def signal_handler(signal, frame):
|
||||
def signal_handler(sig, frame):
|
||||
global server_vent
|
||||
|
||||
LOG.info(
|
||||
@ -158,6 +158,8 @@ def signal_handler(signal, frame):
|
||||
)
|
||||
threads.APRSDThreadList().stop_all()
|
||||
server_event.set()
|
||||
time.sleep(1)
|
||||
signal.signal(signal.SIGTERM, sys.exit(0))
|
||||
|
||||
|
||||
# end signal_handler
|
||||
@ -350,7 +352,7 @@ def send_message(
|
||||
@main.command()
|
||||
@click.option(
|
||||
"--loglevel",
|
||||
default="DEBUG",
|
||||
default="INFO",
|
||||
show_default=True,
|
||||
type=click.Choice(
|
||||
["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"],
|
||||
@ -383,7 +385,20 @@ def send_message(
|
||||
default=False,
|
||||
help="Flush out all old aged messages on disk.",
|
||||
)
|
||||
def server(loglevel, quiet, disable_validation, config_file, flush):
|
||||
@click.option(
|
||||
"--stats-server",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Run a stats web server on port 5001?",
|
||||
)
|
||||
def server(
|
||||
loglevel,
|
||||
quiet,
|
||||
disable_validation,
|
||||
config_file,
|
||||
flush,
|
||||
stats_server,
|
||||
):
|
||||
"""Start the aprsd server process."""
|
||||
global event
|
||||
|
||||
@ -441,12 +456,16 @@ def server(loglevel, quiet, disable_validation, config_file, flush):
|
||||
|
||||
messaging.MsgTrack().restart()
|
||||
|
||||
if stats_server:
|
||||
app = flask.init_flask(config)
|
||||
app.run(host="0.0.0.0", port=5001)
|
||||
|
||||
cntr = 0
|
||||
while not server_event.is_set():
|
||||
# to keep the log noise down
|
||||
if cntr % 6 == 0:
|
||||
if cntr % 12 == 0:
|
||||
tracker = messaging.MsgTrack()
|
||||
# LOG.debug("KeepAlive Tracker({}): {}".format(len(tracker), str(tracker)))
|
||||
LOG.debug("KeepAlive Tracker({}): {}".format(len(tracker), str(tracker)))
|
||||
cntr += 1
|
||||
time.sleep(10)
|
||||
|
||||
|
@ -39,6 +39,7 @@ class MsgTrack:
|
||||
"""
|
||||
|
||||
_instance = None
|
||||
_start_time = None
|
||||
lock = None
|
||||
|
||||
track = {}
|
||||
@ -48,6 +49,7 @@ class MsgTrack:
|
||||
if cls._instance is None:
|
||||
cls._instance = super().__new__(cls)
|
||||
cls._instance.track = {}
|
||||
cls._start_time = datetime.datetime.now()
|
||||
cls._instance.lock = threading.Lock()
|
||||
return cls._instance
|
||||
|
||||
@ -235,7 +237,6 @@ class RawMessage(Message):
|
||||
def send(self):
|
||||
tracker = MsgTrack()
|
||||
tracker.add(self)
|
||||
LOG.debug("Length of MsgTrack is {}".format(len(tracker)))
|
||||
thread = SendMessageThread(message=self)
|
||||
thread.start()
|
||||
|
||||
|
@ -54,13 +54,13 @@ class APRSDThread(threading.Thread, metaclass=abc.ABCMeta):
|
||||
self.thread_stop = True
|
||||
|
||||
def run(self):
|
||||
LOG.info("Starting")
|
||||
LOG.debug("Starting")
|
||||
while not self.thread_stop:
|
||||
can_loop = self.loop()
|
||||
if not can_loop:
|
||||
self.stop()
|
||||
APRSDThreadList().remove(self)
|
||||
LOG.info("Exiting")
|
||||
LOG.debug("Exiting")
|
||||
|
||||
|
||||
class APRSDRXThread(APRSDThread):
|
||||
@ -118,7 +118,6 @@ class APRSDRXThread(APRSDThread):
|
||||
)
|
||||
tracker = messaging.MsgTrack()
|
||||
tracker.remove(ack_num)
|
||||
LOG.debug("Length of MsgTrack is {}".format(len(tracker)))
|
||||
return
|
||||
|
||||
def process_mic_e_packet(self, packet):
|
||||
@ -127,7 +126,6 @@ class APRSDRXThread(APRSDThread):
|
||||
return
|
||||
|
||||
def process_message_packet(self, packet):
|
||||
LOG.info("Got a message packet")
|
||||
fromcall = packet["from"]
|
||||
message = packet.get("message_text", None)
|
||||
|
||||
@ -194,9 +192,8 @@ class APRSDRXThread(APRSDThread):
|
||||
def process_packet(self, packet):
|
||||
"""Process a packet recieved from aprs-is server."""
|
||||
|
||||
LOG.debug("Process packet! {}".format(self.msg_queues))
|
||||
try:
|
||||
LOG.debug("Got message: {}".format(packet))
|
||||
LOG.info("Got message: {}".format(packet))
|
||||
|
||||
msg = packet.get("message_text", None)
|
||||
msg_format = packet.get("format", None)
|
||||
@ -228,7 +225,6 @@ class APRSDTXThread(APRSDThread):
|
||||
def loop(self):
|
||||
try:
|
||||
msg = self.msg_queues["tx"].get(timeout=0.1)
|
||||
LOG.info("TXQ: got message '{}'".format(msg))
|
||||
msg.send()
|
||||
except queue.Empty:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user