on commited on
Commit
e6365e8
·
1 Parent(s): 77f65ab

Expose YouTube manager status on /health (no secrets).

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -730,6 +730,19 @@ def health_public():
730
  'last_error':tsk.get('last_error') or '','source_age':rs.get('source_age'),
731
  'output_seconds':rs.get('output_seconds') or 0})
732
  res=resource_snapshot()
 
 
 
 
 
 
 
 
 
 
 
 
 
733
  return {'application':'running','monitor':'running' if _monitor_alive.is_set() else 'stopped',
734
  'accounts':n,'enabled':enabled,'active_relays':active,
735
  'max_concurrent_relays':max_concurrent_relays(),
@@ -739,6 +752,9 @@ def health_public():
739
  'last_error_user':last_error_user,
740
  'version':APP_VERSION,'rtmp_configured':rtmp_configured(),
741
  'metadata_automation':_oauth_automation_on(),
 
 
 
742
  'broadcasters':per}
743
 
744
  @app.get('/api/health')
 
730
  'last_error':tsk.get('last_error') or '','source_age':rs.get('source_age'),
731
  'output_seconds':rs.get('output_seconds') or 0})
732
  res=resource_snapshot()
733
+ mgr=bool(youtube.manager_thread and youtube.manager_thread.is_alive())
734
+ y_events=0; y_hist=0; y_senders=0; y_status=''; y_skip=''
735
+ try:
736
+ jd=youtube.journal.read()
737
+ y_events=len(jd.get('events') or {})
738
+ y_hist=len(jd.get('history') or [])
739
+ y_status=str(getattr(youtube,'status_text','') or '')[:160]
740
+ y_senders=sum(1 for e in (youtube.senders or {}).values() if e.get('thread') and e['thread'].is_alive())
741
+ skip=getattr(youtube,'_skip_last',None) or {}
742
+ if skip:
743
+ y_skip='; '.join('%s: %s'%(u,str(t)[:80]) for u,t in list(skip.items())[-3:])[:200]
744
+ except Exception:
745
+ pass
746
  return {'application':'running','monitor':'running' if _monitor_alive.is_set() else 'stopped',
747
  'accounts':n,'enabled':enabled,'active_relays':active,
748
  'max_concurrent_relays':max_concurrent_relays(),
 
752
  'last_error_user':last_error_user,
753
  'version':APP_VERSION,'rtmp_configured':rtmp_configured(),
754
  'metadata_automation':_oauth_automation_on(),
755
+ 'youtube_manager':'running' if mgr else 'stopped',
756
+ 'youtube_status':y_status,'youtube_events':y_events,'youtube_history':y_hist,
757
+ 'youtube_senders':y_senders,'youtube_skip':y_skip,
758
  'broadcasters':per}
759
 
760
  @app.get('/api/health')