Skip to content

Commit

Permalink
Fixing empty recommendations for new servers. Also adding firewall in…
Browse files Browse the repository at this point in the history
…formation and fixing up fabfile.
  • Loading branch information
samuelclay committed Mar 19, 2011
1 parent fbfede6 commit b5ea1dc
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 14 deletions.
5 changes: 4 additions & 1 deletion apps/recommendations/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from utils import log as logging
from django.http import HttpResponse
from django.template import RequestContext
from django.shortcuts import render_to_response
from apps.recommendations.models import RecommendedFeed
Expand Down Expand Up @@ -26,4 +27,6 @@ def load_recommended_feed(request):
'usersub' : usersub,
'has_next_page' : len(recommended_feeds) > 1,
'has_previous_page' : page != 0,
}, context_instance=RequestContext(request))
}, context_instance=RequestContext(request))
else:
return HttpResponse("")
12 changes: 6 additions & 6 deletions config/hosts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
127.0.0.1 localhost

# 10.10 app01
10.5.1.100 db01
# 10.5.1.100 db01
# 10.10 task01
10.5.1.101 task02
# 10.5.1.101 task02

199.15.250.228 app01.newsblur.com
199.15.253.162 db01.newsblur.com
199.15.250.229 task01.newsblur.com
199.15.250.230 task02.newsblur.com
199.15.250.228 app01 app01.newsblur.com
199.15.253.162 db01 db01.newsblur.com
199.15.250.229 task01 task01.newsblur.com
199.15.250.230 task02 task02.newsblur.com
6 changes: 4 additions & 2 deletions config/pgbouncer.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
; database name = connect string
[databases]

newsblur = host=db01 port=5432 dbname=newsblur
newsblur = host=db01.newsblur.com port=5432 dbname=newsblur user=newsblur pass=

;; Configuation section
[pgbouncer]

ignore_startup_parameters = application_name

;;;
;;; Administrative settings
;;;
Expand All @@ -27,7 +29,7 @@ unix_socket_dir = /var/run/postgresql
;;;

; any, trust, plain, crypt, md5
auth_type = trust
auth_type = plain
; auth_file = 8.0/main/global/pg_auth
auth_file = /etc/pgbouncer/userlist.txt

Expand Down
1 change: 1 addition & 0 deletions config/pgbouncer_userlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"newsblur" ""
6 changes: 6 additions & 0 deletions config/server_migration_forwarding.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
server {
listen 199.15.250.228:80;
location ~ / {
proxy_pass http://173.230.136.120;
}
}
1 change: 1 addition & 0 deletions config/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ alias cd..='cd ..'

alias smtp='python -m smtpd -n -c DebuggingServer 127.0.0.1:1025'
alias tlnb='echo "----------------\n"; tail -f logs/newsblur.log'
alias sp='~/newsblur/manage.py shell_plus'
alias cdsg='cd ~/staging'
alias cdnb='cd ~/newsblur'

Expand Down
24 changes: 20 additions & 4 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ def backup_postgresql():
def setup_app():
setup_common()
setup_app_motd()
setup_nginx()
setup_gunicorn()
update_gunicorn()
setup_nginx()

def setup_db():
setup_common()
setup_db_firewall()
setup_db_motd()
setup_db_installs()
setup_rabbitmq()
Expand All @@ -119,6 +120,8 @@ def setup_task():
setup_task_motd()
setup_task_installs()
setup_celery()
setup_gunicorn(supervisor=False)
update_gunicorn()

def setup_common():
setup_installs()
Expand Down Expand Up @@ -151,6 +154,9 @@ def setup_installs():
sudo('python ez_setup.py -U setuptools && rm ez_setup.py')
sudo('chsh sclay -s /bin/zsh')

def config_pgbouncer():
put('config/pgbouncer.conf', '/etc/pgbouncer/pgbouncer.ini', use_sudo=True)
put('config/pgbouncer_userlist.txt', '/etc/pgbouncer/userlist.txt', use_sudo=True)

def setup_user():
# run('useradd -c "NewsBlur" -m conesus -s /bin/zsh')
Expand All @@ -168,6 +174,7 @@ def setup_repo():
with cd('~/newsblur'):
run('cp local_settings.py.template local_settings.py')
run('mkdir -p logs')
run('touch logs/newsblur.log')

def setup_local_files():
put("config/toprc", "./.toprc")
Expand Down Expand Up @@ -225,11 +232,12 @@ def setup_app_installs():
def setup_app_motd():
put('config/motd_app.txt', '/etc/motd.tail', use_sudo=True)

def setup_gunicorn():
put('config/supervisor_gunicorn.conf', '/etc/supervisor/conf.d/gunicorn.conf', use_sudo=True)
def setup_gunicorn(supervisor=True):
if supervisor:
put('config/supervisor_gunicorn.conf', '/etc/supervisor/conf.d/gunicorn.conf', use_sudo=True)
with cd('~/code'):
sudo('rm -fr gunicorn')
run('git clone git://github.com/benoitc/gunicorn.git')
sudo('ln -s ~/code/gunicorn/gunicorn /usr/local/lib/python2.6/dist-packages/gunicorn')

def update_gunicorn():
with cd('~/code/gunicorn'):
Expand Down Expand Up @@ -261,6 +269,14 @@ def setup_nginx():
def setup_db_installs():
pass

def setup_db_firewall():
sudo('ufw default deny')
sudo('ufw allow ssh')
sudo('ufw allow 5432')
sudo('ufw allow 27017')
sudo('ufw allow 5672')
sudo('ufw enable')

def setup_db_motd():
put('config/motd_db.txt', '/etc/motd.tail', use_sudo=True)

Expand Down
2 changes: 1 addition & 1 deletion utils/restart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
kill -HUP `cat ~/newsblur/logs/gunicorn.pid`
echo '----\n'
tail -f /home/conesus/newsblur/logs/newsblur.log
tail -f ~/newsblur/logs/newsblur.log

0 comments on commit b5ea1dc

Please sign in to comment.