Permalink
Browse files

Merge branch 'master' of github.com:Doula/Bambino

  • Loading branch information...
2 parents a4b273f + b04ebcc commit 10fcb705f30f12f0f46670ec63329b7248084937 @quezo quezo committed Apr 26, 2012
Showing with 46 additions and 12 deletions.
  1. +32 −0 bambino/appenv.py
  2. +7 −8 bambino/views.py
  3. +1 −1 development.ini
  4. +5 −2 fabfile.py
  5. +1 −1 production.ini
View
@@ -3,6 +3,7 @@
from git import GitCommandError
from git import Repo
from path import path as pathd
+from socket import gethostname
import time
import datetime
@@ -13,6 +14,8 @@
import subprocess
import os
import glob
+import socket
+import re
class Node(object):
@@ -57,6 +60,35 @@ def tag_apps(self, apps_to_tag, tag, message):
def to_json(self):
json.dumps(self.repo_data)
+ @staticmethod
+ def _ip():
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ s.connect(("192.168.201.5",80))
+ out = (s.getsockname()[0])
+ s.close()
+ return out
+
+ @staticmethod
+ def _hostname():
+ from socket import gethostname
+ return gethostname()
+
+ @staticmethod
+ def _site(hostname):
+ sites = {'mktest3-py' : 'mt3', 'mktest2-py' : 'mt2', 'mktest2-py' : 'mt1'}
+ if(hostname in sites):
+ return sites[hostname]
+
+ arr = hostname.split('-')
+ if(len(arr) == 2):
+ return arr[0]
+
+ return hostname
+
+ @staticmethod
+ def get_machine_info():
+ return {'ip' : Node._ip(), 'name' : Node._hostname(), 'site' : Node._site(Node._hostname())}
+
class WebAppDir(pathd):
def __init__(self, filepath):
View
@@ -40,13 +40,12 @@ def register_me(event):
Register this Bambino node with Doula.
"""
settings = event.app.registry.settings
-
- node = {
- 'name': settings['node'],
- 'site': settings['site'],
- 'url' : settings['bambino_url']
- }
-
- registration.register_bambino(node, settings['register_url'])
+
+ machine_info = Node.get_machine_info()
+ #TODO: we're using the IP for now. Once the hostname gets standardized, we'll
+ # move to that
+ machine_info['url'] = 'http://%s:%s' % (machine_info['ip'], settings['port'])
+
+ registration.register_bambino(machine_info, settings['register_url'])
View
@@ -14,7 +14,7 @@ site=Monkey Test One
node=Machine Numero Uno
register_url=http://127.0.0.1:6543/register
bambino_url=http://127.0.0.1:6542
-
+port = 6542
[app:dev]
use = egg:Bambino
View
@@ -11,6 +11,10 @@
supervisor_file = '/etc/supervisor/conf.d/bambino.conf'
def update():
+ if not exists(doula_dir):
+ print "We can go no further, you must run 'fab create_env' before moving on"
+ return
+
with cd(doula_dir):
if not exists('bin'):
run('mkvirtualenv .')
@@ -29,8 +33,7 @@ def update():
restart()
def restart():
- sudo('supervisorctl restart doula_6543')
-
+ sudo('supervisorctl restart bambino_6666')
def create_env(host='mktest1-pyweb.corp.surveymonkey.com'):
_make_base_dir()
View
@@ -13,7 +13,7 @@ register_url=http://doula.corp.surveymonkey.com/register
[server:main]
use = egg:waitress#main
host = 0.0.0.0
-port = 6543
+port = port
# Begin logging configuration

0 comments on commit 10fcb70

Please sign in to comment.