Fix for hanging requests, Remove PID File
- Removed PID file generation, uneeded use matching process to plane-notify name - Add timeout to requests for ADSBX, previously hanging. - Fix exception for Discord
This commit is contained in:
parent
405cc549f9
commit
1366f7d3ca
16
__main__.py
16
__main__.py
|
@ -6,16 +6,6 @@ import traceback
|
|||
if platform.system() == "Windows":
|
||||
from colorama import init
|
||||
init(convert=True)
|
||||
elif platform.system() == "Linux":
|
||||
pid_file_path = "/home/plane-notify/pid.pid"
|
||||
def write_pid_file(filepath):
|
||||
import os
|
||||
pid = str(os.getpid())
|
||||
f = open(filepath, 'w')
|
||||
f.write(pid)
|
||||
f.close()
|
||||
write_pid_file(pid_file_path)
|
||||
print("Made PIDFile")
|
||||
from planeClass import Plane
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
|
@ -63,7 +53,6 @@ def service_exit(signum, frame):
|
|||
if main_config.getboolean('DISCORD', 'ENABLE'):
|
||||
from defDiscord import sendDis
|
||||
sendDis("Service Stop", main_config)
|
||||
os.remove(pid_file_path)
|
||||
raise SystemExit("Service Stop")
|
||||
signal.signal(signal.SIGTERM, service_exit)
|
||||
if os.path.isfile("lookup_route.py"):
|
||||
|
@ -223,7 +212,4 @@ except Exception as e:
|
|||
logging.error(str(traceback.format_exc()))
|
||||
from defDiscord import sendDis
|
||||
sendDis(str("Error Exiting: " + str(e) + "Failed on " + key), main_config, "crash_latest.log")
|
||||
raise e
|
||||
finally:
|
||||
if platform.system() == "Linux":
|
||||
os.remove(pid_file_path)
|
||||
raise e
|
|
@ -12,7 +12,7 @@ api_version = main_config.get('ADSBX', 'API_VERSION')
|
|||
|
||||
def pull(url, headers):
|
||||
try:
|
||||
response = requests.get(url, headers = headers)
|
||||
response = requests.get(url, headers = headers, timeout=30)
|
||||
print ("HTTP Status Code:", response.status_code)
|
||||
response.raise_for_status()
|
||||
except (requests.HTTPError, ConnectionError, requests.Timeout, urllib3.exceptions.ConnectionError) as error_message:
|
||||
|
|
|
@ -9,5 +9,5 @@ def sendDis(message, config, file_name = None, role_id = None):
|
|||
webhook.add_file(file=f.read(), filename=file_name)
|
||||
try:
|
||||
webhook.execute()
|
||||
except requests.Exceptions:
|
||||
except requests.exceptions.RequestException:
|
||||
pass
|
Loading…
Reference in New Issue