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