Skip to content

Commit

Permalink
acquire GUI info through flask api
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Axline committed Oct 9, 2021
1 parent c3e93c3 commit 901b617
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions multivisor/multivisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import time
import weakref
import requests

from blinker import signal

Expand Down Expand Up @@ -244,6 +245,7 @@ def __init__(self, supervisor, *args, **kwargs):
self["supervisor"] = supervisor_name
self["host"] = supervisor["host"]
self["uid"] = uid
self["gui_url"] = self.get_gui_url()

@property
def server(self):
Expand All @@ -253,6 +255,14 @@ def server(self):
def full_name(self):
return self["full_name"]

def get_gui_url(self):
try:
response = requests.post('http://circus.lab/services/supervisor',
json={'host': self["host"], 'process': self["name"]})
return response.json()
except: # JSON error (no process) or can't communicate with server
return ''

def handle_event(self, event):
event_name = event["eventname"]
if event_name.startswith("PROCESS_STATE"):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ flask
gevent
supervisor
six==1.12.0
requests

0 comments on commit 901b617

Please sign in to comment.