2019-12-08 16:15:48 +00:00
|
|
|
from http.server import HTTPServer
|
|
|
|
from owrx.http import RequestHandler
|
2020-03-21 21:40:39 +00:00
|
|
|
from owrx.config import Config
|
2019-12-08 16:15:48 +00:00
|
|
|
from owrx.feature import FeatureDetector
|
2019-12-21 19:58:28 +00:00
|
|
|
from owrx.sdr import SdrService
|
2019-12-08 16:15:48 +00:00
|
|
|
from socketserver import ThreadingMixIn
|
|
|
|
from owrx.sdrhu import SdrHuUpdater
|
|
|
|
from owrx.service import Services
|
|
|
|
from owrx.websocket import WebSocketConnection
|
|
|
|
from owrx.pskreporter import PskReporter
|
2020-03-15 22:34:44 +00:00
|
|
|
from owrx.version import openwebrx_version
|
2019-12-08 16:15:48 +00:00
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
2020-03-15 22:32:19 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
2019-12-08 16:15:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ThreadedHttpServer(ThreadingMixIn, HTTPServer):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
print(
|
|
|
|
"""
|
|
|
|
|
|
|
|
OpenWebRX - Open Source SDR Web App for Everyone! | for license see LICENSE file in the package
|
|
|
|
_________________________________________________________________________________________________
|
|
|
|
|
|
|
|
Author contact info: Jakob Ketterl, DD5JFK <dd5jfk@darc.de>
|
2020-03-15 22:39:38 +00:00
|
|
|
Documentation: https://github.com/jketterl/openwebrx/wiki
|
|
|
|
Support and info: https://groups.io/g/openwebrx
|
2019-12-08 16:15:48 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
|
2020-03-15 22:34:44 +00:00
|
|
|
logger.info("OpenWebRX version {0} starting up...".format(openwebrx_version))
|
|
|
|
|
2020-03-21 21:40:39 +00:00
|
|
|
pm = Config.get()
|
2019-12-08 16:15:48 +00:00
|
|
|
|
2020-03-15 22:32:19 +00:00
|
|
|
configErrors = Config.validateConfig()
|
|
|
|
if configErrors:
|
|
|
|
logger.error(
|
|
|
|
"your configuration contains errors. please address the following errors:"
|
|
|
|
)
|
|
|
|
for e in configErrors:
|
|
|
|
logger.error(e)
|
|
|
|
return
|
|
|
|
|
2019-12-08 16:15:48 +00:00
|
|
|
featureDetector = FeatureDetector()
|
|
|
|
if not featureDetector.is_available("core"):
|
2020-03-15 22:32:19 +00:00
|
|
|
logger.error(
|
2019-12-08 16:15:48 +00:00
|
|
|
"you are missing required dependencies to run openwebrx. "
|
|
|
|
"please check that the following core requirements are installed:"
|
|
|
|
)
|
2020-03-15 22:32:19 +00:00
|
|
|
logger.error(", ".join(featureDetector.get_requirements("core")))
|
2019-12-08 16:15:48 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
# Get error messages about unknown / unavailable features as soon as possible
|
|
|
|
SdrService.loadProps()
|
|
|
|
|
|
|
|
if "sdrhu_key" in pm and pm["sdrhu_public_listing"]:
|
|
|
|
updater = SdrHuUpdater()
|
|
|
|
updater.start()
|
|
|
|
|
|
|
|
Services.start()
|
|
|
|
|
|
|
|
try:
|
2020-03-23 21:09:26 +00:00
|
|
|
server = ThreadedHttpServer(("0.0.0.0", pm["web_port"]), RequestHandler)
|
2019-12-08 16:15:48 +00:00
|
|
|
server.serve_forever()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
WebSocketConnection.closeAll()
|
|
|
|
Services.stop()
|
|
|
|
PskReporter.stop()
|