From 19a0a76452586321e8b346f82609d3c8d5895ad9 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Mon, 11 Jan 2016 10:57:54 +0000 Subject: [PATCH] Added orchestrastatus management command --- orchestra/management/commands/orchestrastatus.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/orchestra/management/commands/orchestrastatus.py b/orchestra/management/commands/orchestrastatus.py index 741981e2..e0db4ec5 100644 --- a/orchestra/management/commands/orchestrastatus.py +++ b/orchestra/management/commands/orchestrastatus.py @@ -50,7 +50,11 @@ class Command(BaseCommand): regex = r'location\s+([^\s]+)\s+{.*uwsgi_pass unix:///var/run/uwsgi/app/%(project_name)s/socket;.*' % context location = re.findall(regex, config) if location: - self.stdout.write(" * location %s" % location[0]) + ip = run("ip a | grep 'inet ' | awk {'print $2'} | grep -v '^127.0.' | head -n 1 | cut -d'/' -f1").stdout.decode() + if not ip: + ip = '127.0.0.1' + location = 'http://%s%s' % (ip, location[0]) + self.stdout.write(" * location %s" % location) else: self.stdout.write(" * location not found") elif service == 'postgresql':