def main() -> NoReturn: set_core_affinity([ int(os.getenv("CORE", "3")), ]) set_realtime_priority(1) while True: time.sleep(0.000001)
def main(): try: set_core_affinity([0, 1, 2, 3]) except Exception: cloudlog.exception("failed to set core affinity") params = Params() dongle_id = params.get("DongleId", encoding='utf-8') UploadQueueCache.initialize(upload_queue) ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id api = Api(dongle_id) conn_retries = 0 while 1: try: cloudlog.event("athenad.main.connecting_ws", ws_uri=ws_uri) ws = create_connection(ws_uri, cookie="jwt=" + api.get_token(), enable_multithread=True, timeout=30.0) cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri) params.delete("PrimeRedirected") conn_retries = 0 cur_upload_items.clear() handle_long_poll(ws) except (KeyboardInterrupt, SystemExit): break except (ConnectionError, TimeoutError, WebSocketException): conn_retries += 1 params.delete("PrimeRedirected") params.delete("LastAthenaPingTime") except socket.timeout: try: r = requests.get( "http://api.commadotai.com/v1/me", allow_redirects=False, headers={"User-Agent": f"openpilot-{get_version()}"}, timeout=15.0) if r.status_code == 302 and r.headers['Location'].startswith( "http://u.web2go.com"): params.put_bool("PrimeRedirected", True) except Exception: cloudlog.exception("athenad.socket_timeout.exception") params.delete("LastAthenaPingTime") except Exception: cloudlog.exception("athenad.main.exception") conn_retries += 1 params.delete("PrimeRedirected") params.delete("LastAthenaPingTime") time.sleep(backoff(conn_retries))
def main(): set_core_affinity(1) set_realtime_priority(1) procs = {} crash_count = 0 modem_killed = False modem_state = "ONLINE" while True: # check critical android services if any(p is None or not p.is_running() for p in procs.values()) or not len(procs): cur = {p: None for p in WATCHED_PROCS} for p in psutil.process_iter(attrs=['cmdline']): cmdline = None if not len( p.info['cmdline']) else p.info['cmdline'][0] if cmdline in WATCHED_PROCS: cur[cmdline] = p if len(procs): for p in WATCHED_PROCS: if cur[p] != procs[p]: cloudlog.event("android service pid changed", proc=p, cur=cur[p], prev=procs[p], error=True) procs.update(cur) if os.path.exists(MODEM_PATH): # check modem state state = get_modem_state() if state != modem_state and not modem_killed: cloudlog.event("modem state changed", state=state) modem_state = state # check modem crashes cnt = get_modem_crash_count() if cnt is not None: if cnt > crash_count: cloudlog.event("modem crash", count=cnt) crash_count = cnt # handle excessive modem crashes if crash_count > MAX_MODEM_CRASHES and not modem_killed: cloudlog.event("killing modem", error=True) with open("/sys/kernel/debug/msm_subsys/modem", "w") as f: f.write("put") modem_killed = True time.sleep(1)
def main(): try: set_core_affinity([0, 1, 2, 3]) except Exception: cloudlog.exception("failed to set core affinity") params = Params() dongle_id = params.get("DongleId", encoding='utf-8') UploadQueueCache.initialize(upload_queue) ws_uri = ATHENA_HOST + "/ws/v2/" + dongle_id api = Api(dongle_id) conn_retries = 0 while 1: try: cloudlog.event("athenad.main.connecting_ws", ws_uri=ws_uri) ws = create_connection(ws_uri, cookie="jwt=" + api.get_token(), enable_multithread=True, timeout=30.0) cloudlog.event("athenad.main.connected_ws", ws_uri=ws_uri) conn_retries = 0 cur_upload_items.clear() handle_long_poll(ws) except (KeyboardInterrupt, SystemExit): break except (ConnectionError, TimeoutError, WebSocketException): conn_retries += 1 params.delete("LastAthenaPingTime") except socket.timeout: params.delete("LastAthenaPingTime") except Exception: cloudlog.exception("athenad.main.exception") conn_retries += 1 params.delete("LastAthenaPingTime") time.sleep(backoff(conn_retries))
def main(): set_core_affinity(int(os.getenv("CORE", "3"))) set_realtime_priority(1) while True: time.sleep(0.000001)
def main(): set_core_affinity(1) set_realtime_priority(1) procs = {} crash_count = 0 modem_killed = False modem_state = "ONLINE" androidLog = messaging.sub_sock('androidLog') while True: # check critical android services if any(p is None or not p.is_running() for p in procs.values()) or not len(procs): cur = {p: None for p in WATCHED_PROCS} for p in psutil.process_iter(attrs=['cmdline']): cmdline = None if not len( p.info['cmdline']) else p.info['cmdline'][0] if cmdline in WATCHED_PROCS: cur[cmdline] = p if len(procs): for p in WATCHED_PROCS: if cur[p] != procs[p]: cloudlog.event("android service pid changed", proc=p, cur=cur[p], prev=procs[p], error=True) procs.update(cur) # log caught NetworkPolicy exceptions msgs = messaging.drain_sock(androidLog) for m in msgs: try: if m.androidLog.tag == "NetworkPolicy" and m.androidLog.message.startswith( "problem with advise persist threshold"): cloudlog.event("network policy exception caught", androidLog=m.androidLog, error=True) except UnicodeDecodeError: pass if os.path.exists(MODEM_PATH): # check modem state state = get_modem_state() if state != modem_state and not modem_killed: cloudlog.event("modem state changed", state=state) modem_state = state # check modem crashes cnt = get_modem_crash_count() if cnt is not None: if cnt > crash_count: cloudlog.event("modem crash", count=cnt) crash_count = cnt # handle excessive modem crashes if crash_count > MAX_MODEM_CRASHES and not modem_killed: cloudlog.event("killing modem", error=True) with open("/sys/kernel/debug/msm_subsys/modem", "w") as f: f.write("put") modem_killed = True time.sleep(1)
def main(): set_core_affinity(3) set_realtime_priority(1) while True: time.sleep(0.000001)