Created
August 3, 2014 18:26
-
-
Save jbradach/a618b13da6f7fc843511 to your computer and use it in GitHub Desktop.
Connect to uWSGI Stats Server using Unix domain sockets in Flask.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/uwsgistat/') | |
@app.route('/uwsgistat/<appchoice>') | |
def uwsgistat(appchoice = None): | |
if appchoice == None: | |
return redirect(url_for('index')) | |
statsocket = '/tmp/' + appchoice + '-stat.sock' | |
if os.path.exists(statsocket): | |
client = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM ) | |
client.connect(statsocket) | |
data = client.recv(2048) | |
client.close() | |
data = json.loads(data) | |
return json.jsonify(data) | |
else: | |
return 'invalid uwsgi socket' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment