Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing empty recommendations for new servers. Also adding firewall in…

…formation and fixing up fabfile.
  • Loading branch information...
commit b5ea1dcdf6a9cd312aeb2c3ebe39ea8f3531ef70 1 parent fbfede6
Samuel Clay authored
5 apps/recommendations/views.py
View
@@ -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
@@ -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 config/hosts
View
@@ -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 config/pgbouncer.conf
View
@@ -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
;;;
@@ -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
1  config/pgbouncer_userlist.txt
View
@@ -0,0 +1 @@
+"newsblur" ""
6 config/server_migration_forwarding.txt
View
@@ -0,0 +1,6 @@
+server {
+ listen 199.15.250.228:80;
+ location ~ / {
+ proxy_pass http://173.230.136.120;
+ }
+}
1  config/zshrc
View
@@ -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'
24 fabfile.py
View
@@ -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()
@@ -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()
@@ -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')
@@ -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")
@@ -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'):
@@ -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)
2  utils/restart
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.