Permalink
Browse files

fixed a few loose ends and added sample configuration files

  • Loading branch information...
1 parent 8909646 commit 5319f32b00f7c1b6337ea2aac56f7396981530ae Jorge Handl committed Jan 17, 2012
Showing with 285 additions and 241 deletions.
  1. +0 −2 api/amazon_credential.py
  2. +1 −1 api/dostartapi.sh
  3. +4 −4 api/settings.py
  4. +0 −107 api/storage.py
  5. +0 −2 backoffice/amazon_credential.py
  6. +3 −3 backoffice/settings.py
  7. +0 −1 nebu/controller.py
  8. +35 −0 nebu/sample-config/etc/init.d/indexengine-nebu-controller
  9. +12 −0 nebu/sample-config/etc/rc.local
  10. +8 −0 nebu/sample-config/etc/service/indexengine-nebu-controller/run
  11. +3 −3 nebu/settings.py
  12. +11 −0 sample-config/etc/hosts
  13. +25 −0 sample-config/etc/nginx/sites-available/api-uwsgi.conf
  14. +16 −0 sample-config/etc/nginx/sites-available/backoffice_fcgi.conf
  15. +47 −0 sample-config/etc/nginx/sites-available/storefront_fcgi.conf
  16. +1 −0 sample-config/etc/nginx/sites-enabled/api-uwsgi.conf
  17. +1 −0 sample-config/etc/nginx/sites-enabled/backoffice_fcgi.conf
  18. +1 −0 sample-config/etc/nginx/sites-enabled/storefront_fcgi.conf
  19. +18 −0 sample-config/etc/rc.local
  20. +58 −0 sample-config/etc/security/limits.conf
  21. +6 −0 sample-config/etc/service/indexengine-nebu-deploy-manager/run
  22. +10 −0 sample-config/etc/service/indexengine-nebu-populator/run
  23. +10 −0 sample-config/etc/service/indexengine-nebu-supervisor/run
  24. +6 −0 sample-config/etc/service/indexengine-nebu-worker-manager/run
  25. BIN storage/.lib.swp
  26. +0 −2 storefront/amazon_credential.py
  27. +2 −2 storefront/authorize.settings.debug
  28. +2 −2 storefront/authorize.settings.prod
  29. +4 −4 storefront/settings.py
  30. +0 −107 storefront/storage.py
  31. +1 −1 storefront/templates/includes/menu.html
View
@@ -1,2 +0,0 @@
-AMAZON_USER = ""
-AMAZON_PASSWORD = ""
View
@@ -10,6 +10,6 @@ echo "######################## START API "`date`" ##########################" >
export PYTHONPATH=.:..
-nohup uwsgi-python2.6 -C -s /var/nginx/api-uwsgi.sock -i -M -w wsgi -z 30 -p 150 -l 50 -L -R 10000 -b 8192 --no-orphans --pidfile pid 2>$ERRORLOG | $TEE | $ROTATELOG &
+nohup uwsgi_python -C -s /var/nginx/api-uwsgi.sock -i -M -z 30 -p 150 -l 50 -L -R 10000 -b 8192 --no-orphans --pidfile pid 2>$ERRORLOG | $TEE | $ROTATELOG &
View
@@ -76,12 +76,12 @@
EMAIL_HOST='localhost'
EMAIL_PORT=25
-EMAIL_HOST_USER='email%localhost'
+EMAIL_HOST_USER='user%localhost'
EMAIL_HOST_PASSWORD='****'
# Seeds for the api key generation. These are examples, they should be changed at each installation.
# You can find good seeds at https://www.grc.com/passwords.htm
-APIKEY_KEY='BB20B26D35578F0CD53B1F9F270DEC2410F1BA90FB1BADCC3D79875DEC534C04'
-ONETIMEPASS_KEY='86CB9927F58AE49255935D50CE4D372E57873D8C83B4B68E71818C7316D7F14D'
-FORGOTPASS_KEY='42015FF556615CD6A9FB6884EB4B360CAE118B27E8597B4A1AF435DB703784E3'
+APIKEY_KEY='5AD2CFAEEFAA93EC114DB414D7C3C18BBFB591784729DA33B2D779E65DB65DA5'
+ONETIMEPASS_KEY='AC031B479497B86321EAC0E2D66A5A9C6EC6B4F891174E8016420DA1B9CC3320'
+FORGOTPASS_KEY='2455B8EFEBBED1367A4DC2B732DBF08EF6BA5E009CC9C97A192C2C442BDD091A'
View
@@ -1,107 +0,0 @@
-
-''' =========================
- Interaction with SimpleDB
- ========================= '''
-
-import boto
-import hashlib
-import zlib
-import time
-import sys
-import traceback
-import datetime
-
-from amazon_credential import AMAZON_USER, AMAZON_PASSWORD
-
-from django.conf import settings
-
-def get_connection():
- return boto.connect_sdb(AMAZON_USER, AMAZON_PASSWORD)
-
-def get_ids(index_code, doc_id):
- md5 = hashlib.md5()
- md5.update(index_code);
- md5.update(doc_id);
- domain_num = zlib.crc32(md5.digest()) % 100
- domain_id = str(domain_num).rjust(3,'0')
- item_id = index_code+'|'+doc_id
- return domain_id, item_id
-
-VALUE_MAX_LENGTH = 1024
-def storage_add(index_code, doc_id, content):
- domain_id, item_id = get_ids(index_code, doc_id)
- try:
- sdb = get_connection()
- domain = sdb.get_domain(domain_id)
- item = domain.new_item(item_id)
- item['timestamp'] = time.time()
- limit = VALUE_MAX_LENGTH-2
- for key, txt in content.iteritems():
- n = 0
- i = 1
- while len(txt) > n:
- part = '['+txt[n:n+limit]+']'
- item['_'+str(i)+'_'+key] = part
- n += limit
- i += 1
- item.save()
- return ""
- except:
- return sys.exc_info()
-
-def storage_get(index_code, doc_id):
- domain_id, item_id = get_ids(index_code, doc_id)
- try:
- sdb = get_connection()
- domain = sdb.get_domain(domain_id)
- item = domain.get_item('|%s|DOC|%s' % (settings.STORAGE_ENV, item_id))
- return item_to_doc(item) if item is not None else None
- except:
- traceback.print_exc()
- return {}, sys.exc_info()
-
-def storage_del(index_code, doc_id):
- domain_id, item_id = get_ids(index_code, doc_id)
- try:
- sdb = get_connection()
- domain = sdb.get_domain(domain_id)
- domain.delete_attributes('DOC|'+item_id)
- return ""
- except:
- return sys.exc_info()
-
-
-def item_to_doc(item):
- doc = {}
- vars = {}
- cats = {}
- item = dict(item)
-
- fields = item['item_fields'].split(',')
-
- for k, v in item.iteritems():
- if k.startswith('user_boost_'):
- vars[k[11:]] = v
- if k.startswith('user_category_'):
- cats[k[14:]] = v
-
- for f in fields:
- v = ''
- p = 1
- while True:
- part = item.get('_%s_%d' % (f, p))
- if part:
- v += part
- p += 1
- else:
- break
- if f == 'timestamp':
- doc[f] = '%s (%s)' % (v, datetime.datetime.fromtimestamp(int(v)))
- else:
- doc[f] = v
-
- return { 'fields': doc, 'variables': vars, 'categories': cats }
-
-
-
-
@@ -1,2 +0,0 @@
-AMAZON_USER = ""
-AMAZON_PASSWORD = ""
View
@@ -87,7 +87,7 @@
# Seeds for the api key generation. These are examples, they should be changed at each installation.
# You can find good seeds at https://www.grc.com/passwords.htm
-APIKEY_KEY='BB20B26D35578F0CD53B1F9F270DEC2410F1BA90FB1BADCC3D79875DEC534C04'
-ONETIMEPASS_KEY='86CB9927F58AE49255935D50CE4D372E57873D8C83B4B68E71818C7316D7F14D'
-FORGOTPASS_KEY='42015FF556615CD6A9FB6884EB4B360CAE118B27E8597B4A1AF435DB703784E3'
+APIKEY_KEY='5AD2CFAEEFAA93EC114DB414D7C3C18BBFB591784729DA33B2D779E65DB65DA5'
+ONETIMEPASS_KEY='AC031B479497B86321EAC0E2D66A5A9C6EC6B4F891174E8016420DA1B9CC3320'
+FORGOTPASS_KEY='2455B8EFEBBED1367A4DC2B732DBF08EF6BA5E009CC9C97A192C2C442BDD091A'
View
@@ -4,7 +4,6 @@
import os
import signal
import systemutils
-import subprocess
import flaptor.indextank.rpc.Controller as TController
from flaptor.indextank.rpc.ttypes import WorkerMountStats, WorkerLoadStats, IndexStats
@@ -0,0 +1,35 @@
+#! /bin/sh
+
+PATH=.:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+NAME=indexengine-nebu-controller
+
+. /lib/lsb/init-functions
+
+case "$1" in
+ start)
+ log_daemon_msg "Starting" "$NAME"
+ svc -u /etc/service/$NAME
+ log_end_msg $?
+ ;;
+ stop)
+ cd $APP_DIR
+ log_daemon_msg "Stopping" "$NAME"
+ svc -d /etc/service/$NAME
+ log_end_msg $?
+ ;;
+ restart)
+ log_daemon_msg "Restarting" "$NAME"
+ svc -t /etc/service/$NAME
+ log_end_msg $?
+ ;;
+ status)
+ svok /etc/service/$NAME
+ log_end_msg $?
+ ;;
+ *)
+ N=/etc/init.d/$NAME
+ echo "Usage: $N {start|stop|restart|status}" >&2
+ exit 1
+ ;;
+esac
+
@@ -0,0 +1,12 @@
+if [ ! -d /mnt/logs/controller ]; then
+ rm -fr /etc/service/indexengine-nebu-controller/log/main
+ mkdir -p /mnt/logs/controller /mnt/indexes
+ ln -s /mnt/logs/controller /etc/service/indexengine-nebu-controller/log/main
+ echo PROD >/mnt/env.name
+ chown -R indextank:indextank /mnt
+ ln -s /mnt /data
+fi
+
+/usr/bin/svscanboot &
+exit 0
+
@@ -0,0 +1,8 @@
+#!/bin/bash
+cd /home/indextank/nebu
+
+echo "Supervise starting controller"
+# start a local controller
+exec sudo -u indextank DJANGO_SETTINGS_MODULE=settings PYTHONPATH=../ /usr/bin/python controller.py 2>&1
+echo "Supervise (controller) ending"
+
View
@@ -75,7 +75,7 @@
# Seeds for the api key generation. These are examples, they should be changed at each installation.
# You can find good seeds at https://www.grc.com/passwords.htm
-APIKEY_KEY='BB20B26D35578F0CD53B1F9F270DEC2410F1BA90FB1BADCC3D79875DEC534C04'
-ONETIMEPASS_KEY='86CB9927F58AE49255935D50CE4D372E57873D8C83B4B68E71818C7316D7F14D'
-FORGOTPASS_KEY='42015FF556615CD6A9FB6884EB4B360CAE118B27E8597B4A1AF435DB703784E3'
+APIKEY_KEY='5AD2CFAEEFAA93EC114DB414D7C3C18BBFB591784729DA33B2D779E65DB65DA5'
+ONETIMEPASS_KEY='AC031B479497B86321EAC0E2D66A5A9C6EC6B4F891174E8016420DA1B9CC3320'
+FORGOTPASS_KEY='2455B8EFEBBED1367A4DC2B732DBF08EF6BA5E009CC9C97A192C2C442BDD091A'
View
@@ -0,0 +1,11 @@
+127.0.0.1 localhost
+
+127.0.0.1 database api storage deploymanager workermanager fend
+
+# The following lines are desirable for IPv6 capable hosts
+::1 ip6-localhost ip6-loopback
+fe00::0 ip6-localnet
+ff00::0 ip6-mcastprefix
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
+ff02::3 ip6-allhosts
@@ -0,0 +1,25 @@
+ upstream api {
+ ip_hash;
+ server unix:/var/nginx/api-uwsgi.sock;
+ }
+
+ server {
+ listen 80;
+ listen 443 default ssl;
+ server_name *.api.indextank.com;
+ client_max_body_size 20m;
+
+ location / {
+ limit_conn one 45;
+ uwsgi_pass api;
+ include uwsgi_params;
+ }
+
+ error_page 411 = @empty_body;
+
+ location @empty_body {
+ uwsgi_pass api;
+ include uwsgi_params;
+ }
+ }
+
@@ -0,0 +1,16 @@
+ server {
+ listen 80;
+ server_name backoffice.indextank.com;
+ client_max_body_size 1m;
+
+ location / {
+ fastcgi_pass 127.0.0.1:4200;
+ include fastcgi_params;
+ }
+
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+ }
+
@@ -0,0 +1,47 @@
+ server {
+ listen 80;
+ server_name indextank.com www.indextank.com;
+ client_max_body_size 1m;
+
+ location / {
+ fastcgi_pass 127.0.0.1:4300;
+ include fastcgi_params;
+ }
+
+ location /_static {
+ expires 24h;
+ autoindex on;
+ alias /home/indextank/storefront/static/;
+ }
+
+ location /nginx_status {
+ stub_status on;
+ access_log off;
+ deny all;
+ allow 127.0.0.1;
+ }
+
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+ }
+
+ server {
+ listen 443;
+ ssl on;
+ server_name indextank.com www.indextank.com;
+ client_max_body_size 1m;
+
+ location / {
+ fastcgi_pass 127.0.0.1:4300;
+ include fastcgi_params;
+ fastcgi_param HTTPS on;
+ }
+
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+ }
+
View
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+#
+# rc.local
+#
+# This script is executed at the end of each multiuser runlevel.
+# Make sure that the script will "exit 0" on success or any other
+# value on error.
+#
+# In order to enable or disable this script just change the execution
+# bits.
+#
+# By default this script does nothing.
+
+rm -fr /mnt/lost+found/
+mkdir -p /data/pids /data/bkp /data/logs/api-rot
+echo PROD >/data/env.name
+chown -R indextank:indextank /mnt
+exit 0
Oops, something went wrong.

0 comments on commit 5319f32

Please sign in to comment.