mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
Adding full bootstrapping to fabfile.
This commit is contained in:
parent
5f584d0b2c
commit
b22cada5e4
14 changed files with 846 additions and 19 deletions
|
@ -402,12 +402,12 @@ def load_starred_stories(request):
|
|||
|
||||
@json.json_view
|
||||
def load_river_stories(request):
|
||||
limit = 25
|
||||
offset = 0
|
||||
start = datetime.datetime.utcnow()
|
||||
user = get_user(request)
|
||||
feed_ids = [int(feed_id) for feed_id in request.POST.getlist('feeds') if feed_id]
|
||||
original_feed_ids = list(feed_ids)
|
||||
offset = int(request.REQUEST.get('offset', 0))
|
||||
limit = int(request.REQUEST.get('limit', 25))
|
||||
page = int(request.REQUEST.get('page', 0))+1
|
||||
read_stories_count = int(request.REQUEST.get('read_stories_count', 0))
|
||||
bottom_delta = datetime.timedelta(days=settings.DAYS_OF_UNREAD)
|
||||
|
@ -420,8 +420,7 @@ def load_river_stories(request):
|
|||
# Fetch all stories at and before the page number.
|
||||
# Not a single page, because reading stories can move them up in the unread order.
|
||||
# `read_stories_count` is an optimization, works best when all 25 stories before have been read.
|
||||
# if page: offset = limit * page
|
||||
if page: limit = limit * page - read_stories_count
|
||||
limit = limit * page - read_stories_count
|
||||
|
||||
# Read stories to exclude
|
||||
read_stories = MUserStory.objects(user_id=user.pk, feed_id__in=feed_ids).only('story')
|
||||
|
|
|
@ -100,16 +100,15 @@ class Feed(models.Model):
|
|||
if feedfinder.isFeed(url):
|
||||
feed = cls.objects.create(feed_address=url)
|
||||
feed.update()
|
||||
feed = Feed.objects.get(pk=feed.pk)
|
||||
feed = cls.objects.get(pk=feed.pk)
|
||||
else:
|
||||
feed_finder_url = feedfinder.feed(url)
|
||||
print "URL: %s %s" % (url, feed_finder_url)
|
||||
if feed_finder_url:
|
||||
feed = by_url(feed_finder_url)
|
||||
if not feed:
|
||||
feed = cls.objects.create(feed_address=feed_finder_url)
|
||||
feed.update()
|
||||
feed = Feed.objects.get(pk=feed.pk)
|
||||
feed = cls.objects.get(pk=feed.pk)
|
||||
else:
|
||||
feed = feed[0]
|
||||
|
||||
|
@ -117,7 +116,7 @@ class Feed(models.Model):
|
|||
|
||||
@classmethod
|
||||
def task_feeds(cls, feeds, queue_size=12):
|
||||
print " ---> Tasking %s feeds..." % feeds.count()
|
||||
logging.debug(" ---> Tasking %s feeds..." % feeds.count())
|
||||
|
||||
publisher = Task.get_publisher()
|
||||
|
||||
|
|
0
config/.aliases
Normal file
0
config/.aliases
Normal file
13
config/gunicorn_conf.py
Normal file
13
config/gunicorn_conf.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
import os
|
||||
|
||||
def numCPUs():
|
||||
if not hasattr(os, "sysconf"):
|
||||
raise RuntimeError("No sysconf detected.")
|
||||
return os.sysconf("SC_NPROCESSORS_ONLN")
|
||||
|
||||
bind = "127.0.0.1:8000"
|
||||
pidfile = "/home/conesus/newsblur/logs/gunicorn.pid"
|
||||
logfile = "/home/conesus/newsblur/logs/production.log"
|
||||
loglevel = "debug"
|
||||
name = "newsblur"
|
||||
workers = numCPUs() * 2
|
55
config/newsblur.conf
Normal file
55
config/newsblur.conf
Normal file
|
@ -0,0 +1,55 @@
|
|||
upstream app_server {
|
||||
server 127.0.0.1:8000 fail_timeout=1;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80 default;
|
||||
client_max_body_size 4G;
|
||||
server_name _;
|
||||
|
||||
location /media/admin/ {
|
||||
alias /usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/django/contrib/admin/media/;
|
||||
}
|
||||
location /media/ {
|
||||
expires max;
|
||||
root /home/conesus/newsblur;
|
||||
}
|
||||
location /favicon.ico {
|
||||
alias /home/conesus/newsblur/media/img/favicon.png;
|
||||
expires max;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ^~ /crossdomain.xml {
|
||||
expires max;
|
||||
alias /home/conesus/newsblur/media/crossdomain.xml;
|
||||
types {
|
||||
text/x-cross-domain-policy xml;
|
||||
}
|
||||
}
|
||||
|
||||
location ^~ /robots.txt {
|
||||
expires max;
|
||||
alias /home/conesus/newsblur/media/robots.txt;
|
||||
}
|
||||
|
||||
location /munin/ {
|
||||
alias /var/cache/munin/www/;
|
||||
}
|
||||
|
||||
location / {
|
||||
if (-f /home/conesus/newsblur/media/maintenance.html) {
|
||||
rewrite ^(.*)$ /media/maintenance.html last;
|
||||
break;
|
||||
}
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
|
||||
if (!-f $request_filename) {
|
||||
proxy_pass http://app_server;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
363
config/nginx-init
Normal file
363
config/nginx-init
Normal file
|
@ -0,0 +1,363 @@
|
|||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: nginx
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: nginx init.d dash script for Ubuntu <=9.10.
|
||||
# Description: nginx init.d dash script for Ubuntu <=9.10.
|
||||
### END INIT INFO
|
||||
#------------------------------------------------------------------------------
|
||||
# nginx - this Debian Almquist shell (dash) script, starts and stops the nginx
|
||||
# daemon for ubuntu 9.10 and lesser version numbered releases.
|
||||
#
|
||||
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
|
||||
# proxy and IMAP/POP3 proxy server. This \
|
||||
# script will manage the initiation of the \
|
||||
# server and it's process state.
|
||||
#
|
||||
# processname: nginx
|
||||
# config: /usr/local/nginx/conf/nginx.conf
|
||||
# pidfile: /acronymlabs/server/nginx.pid
|
||||
# Provides: nginx
|
||||
#
|
||||
# Author: Jason Giedymin
|
||||
# <jason.giedymin AT gmail.com>.
|
||||
#
|
||||
# Version: 2.0 02-NOV-2009 jason.giedymin AT gmail.com
|
||||
# Notes: nginx init.d dash script for Ubuntu <=9.10.
|
||||
#
|
||||
# This script's project home is:
|
||||
# http://code.google.com/p/nginx-init-ubuntu/
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
# MIT X11 License
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Copyright (c) 2009 Jason Giedymin, http://Amuxbit.com formerly
|
||||
# http://AcronymLabs.com
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Functions
|
||||
#------------------------------------------------------------------------------
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Consts
|
||||
#------------------------------------------------------------------------------
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DAEMON=/usr/local/sbin/nginx
|
||||
|
||||
PS="nginx"
|
||||
PIDNAME="nginx" #lets you do $PS-slave
|
||||
PIDFILE=$PIDNAME.pid #pid file
|
||||
PIDSPATH=/var/run
|
||||
|
||||
DESCRIPTION="Nginx Server..."
|
||||
|
||||
RUNAS=root #user to run as
|
||||
|
||||
SCRIPT_OK=0 #ala error codes
|
||||
SCRIPT_ERROR=1 #ala error codes
|
||||
TRUE=1 #boolean
|
||||
FALSE=0 #boolean
|
||||
|
||||
lockfile=/var/lock/subsys/nginx
|
||||
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Simple Tests
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#test if nginx is a file and executable
|
||||
test -x $DAEMON || exit 0
|
||||
|
||||
# Include nginx defaults if available
|
||||
if [ -f /etc/default/nginx ] ; then
|
||||
. /etc/default/nginx
|
||||
fi
|
||||
|
||||
#set exit condition
|
||||
#set -e
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
setFilePerms(){
|
||||
|
||||
if [ -f $PIDSPATH/$PIDFILE ]; then
|
||||
chmod 400 $PIDSPATH/$PIDFILE
|
||||
fi
|
||||
}
|
||||
|
||||
configtest() {
|
||||
$DAEMON -t -c $NGINX_CONF_FILE
|
||||
}
|
||||
|
||||
getPSCount() {
|
||||
return `pgrep -f $PS | wc -l`
|
||||
}
|
||||
|
||||
isRunning() {
|
||||
if [ $1 ]; then
|
||||
pidof_daemon $1
|
||||
PID=$?
|
||||
|
||||
if [ $PID -gt 0 ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
pidof_daemon
|
||||
PID=$?
|
||||
|
||||
if [ $PID -gt 0 ]; then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
#courtesy of php-fpm
|
||||
wait_for_pid () {
|
||||
try=0
|
||||
|
||||
while test $try -lt 35 ; do
|
||||
|
||||
case "$1" in
|
||||
'created')
|
||||
if [ -f "$2" ] ; then
|
||||
try=''
|
||||
break
|
||||
fi
|
||||
;;
|
||||
|
||||
'removed')
|
||||
if [ ! -f "$2" ] ; then
|
||||
try=''
|
||||
break
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
#echo -n .
|
||||
try=`expr $try + 1`
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
status(){
|
||||
isRunning
|
||||
isAlive=$?
|
||||
|
||||
if [ "${isAlive}" -eq $TRUE ]; then
|
||||
echo "$PIDNAME found running with processes: `pidof $PS`"
|
||||
else
|
||||
echo "$PIDNAME is NOT running."
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
removePIDFile(){
|
||||
if [ $1 ]; then
|
||||
if [ -f $1 ]; then
|
||||
rm -f $1
|
||||
fi
|
||||
else
|
||||
#Do default removal
|
||||
if [ -f $PIDSPATH/$PIDFILE ]; then
|
||||
rm -f $PIDSPATH/$PIDFILE
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
log_daemon_msg "Starting $DESCRIPTION"
|
||||
|
||||
isRunning
|
||||
isAlive=$?
|
||||
|
||||
if [ "${isAlive}" -eq $TRUE ]; then
|
||||
log_end_msg $SCRIPT_ERROR
|
||||
else
|
||||
start-stop-daemon --start --quiet --chuid $RUNAS --pidfile $PIDSPATH/$PIDFILE --exec $DAEMON \
|
||||
-- -c $NGINX_CONF_FILE
|
||||
setFilePerms
|
||||
log_end_msg $SCRIPT_OK
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
log_daemon_msg "Stopping $DESCRIPTION"
|
||||
|
||||
isRunning
|
||||
isAlive=$?
|
||||
if [ "${isAlive}" -eq $TRUE ]; then
|
||||
start-stop-daemon --stop --quiet --pidfile $PIDSPATH/$PIDFILE
|
||||
|
||||
wait_for_pid 'removed' $PIDSPATH/$PIDFILE
|
||||
|
||||
if [ -n "$try" ] ; then
|
||||
log_end_msg $SCRIPT_ERROR
|
||||
else
|
||||
removePIDFile
|
||||
log_end_msg $SCRIPT_OK
|
||||
fi
|
||||
|
||||
else
|
||||
log_end_msg $SCRIPT_ERROR
|
||||
fi
|
||||
}
|
||||
|
||||
reload() {
|
||||
configtest || return $?
|
||||
|
||||
log_daemon_msg "Reloading (via HUP) $DESCRIPTION"
|
||||
|
||||
isRunning
|
||||
if [ $? -eq $TRUE ]; then
|
||||
`killall -HUP $PS` #to be safe
|
||||
|
||||
log_end_msg $SCRIPT_OK
|
||||
else
|
||||
log_end_msg $SCRIPT_ERROR
|
||||
fi
|
||||
}
|
||||
|
||||
quietupgrade() {
|
||||
log_daemon_msg "Peforming Quiet Upgrade $DESCRIPTION"
|
||||
|
||||
isRunning
|
||||
isAlive=$?
|
||||
if [ "${isAlive}" -eq $TRUE ]; then
|
||||
kill -USR2 `cat $PIDSPATH/$PIDFILE`
|
||||
kill -WINCH `cat $PIDSPATH/$PIDFILE.oldbin`
|
||||
|
||||
isRunning
|
||||
isAlive=$?
|
||||
if [ "${isAlive}" -eq $TRUE ]; then
|
||||
kill -QUIT `cat $PIDSPATH/$PIDFILE.oldbin`
|
||||
wait_for_pid 'removed' $PIDSPATH/$PIDFILE.oldbin
|
||||
removePIDFile $PIDSPATH/$PIDFILE.oldbin
|
||||
|
||||
log_end_msg $SCRIPT_OK
|
||||
else
|
||||
log_end_msg $SCRIPT_ERROR
|
||||
|
||||
log_daemon_msg "ERROR! Reverting back to original $DESCRIPTION"
|
||||
|
||||
kill -HUP `cat $PIDSPATH/$PIDFILE`
|
||||
kill -TERM `cat $PIDSPATH/$PIDFILE.oldbin`
|
||||
kill -QUIT `cat $PIDSPATH/$PIDFILE.oldbin`
|
||||
|
||||
wait_for_pid 'removed' $PIDSPATH/$PIDFILE.oldbin
|
||||
removePIDFile $PIDSPATH/$PIDFILE.oldbin
|
||||
|
||||
log_end_msg $SCRIPT_ok
|
||||
fi
|
||||
else
|
||||
log_end_msg $SCRIPT_ERROR
|
||||
fi
|
||||
}
|
||||
|
||||
terminate() {
|
||||
log_daemon_msg "Force terminating (via KILL) $DESCRIPTION"
|
||||
|
||||
PIDS=`pidof $PS` || true
|
||||
|
||||
[ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`
|
||||
|
||||
for i in $PIDS; do
|
||||
if [ "$i" = "$PIDS2" ]; then
|
||||
kill $i
|
||||
wait_for_pid 'removed' $PIDSPATH/$PIDFILE
|
||||
removePIDFile
|
||||
fi
|
||||
done
|
||||
|
||||
log_end_msg $SCRIPT_OK
|
||||
}
|
||||
|
||||
destroy() {
|
||||
log_daemon_msg "Force terminating and may include self (via KILLALL) $DESCRIPTION"
|
||||
killall $PS -q >> /dev/null 2>&1
|
||||
log_end_msg $SCRIPT_OK
|
||||
}
|
||||
|
||||
pidof_daemon() {
|
||||
PIDS=`pidof $PS` || true
|
||||
|
||||
[ -e $PIDSPATH/$PIDFILE ] && PIDS2=`cat $PIDSPATH/$PIDFILE`
|
||||
|
||||
for i in $PIDS; do
|
||||
if [ "$i" = "$PIDS2" ]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|force-reload)
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
;;
|
||||
reload)
|
||||
$1
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
configtest)
|
||||
$1
|
||||
;;
|
||||
quietupgrade)
|
||||
$1
|
||||
;;
|
||||
terminate)
|
||||
$1
|
||||
;;
|
||||
destroy)
|
||||
$1
|
||||
;;
|
||||
*)
|
||||
FULLPATH=/etc/init.d/$PS
|
||||
echo "Usage: $FULLPATH {start|stop|restart|force-reload|status|configtest|quietupgrade|terminate|destroy}"
|
||||
echo " The 'destroy' command should only be used as a last resort."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
27
config/nginx.conf
Normal file
27
config/nginx.conf
Normal file
|
@ -0,0 +1,27 @@
|
|||
worker_processes 1;
|
||||
user nginx nginx;
|
||||
pid /opt/nginx/logs/nginx.pid;
|
||||
error_log /opt/nginx/logs/error.log;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
accept_mutex off;
|
||||
}
|
||||
|
||||
http {
|
||||
access_log /var/log/nginx/access.log;
|
||||
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
|
||||
gzip on;
|
||||
gzip_static on;
|
||||
gzip_comp_level 2;
|
||||
gzip_min_length 1000;
|
||||
gzip_proxied expired no-cache no-store private auth;
|
||||
gzip_types text/plain text/html application/xml text/css application/x-javascript application/javascript text/javascript application/xml application/xml+rss;
|
||||
gzip_vary on;
|
||||
|
||||
include /usr/local/nginx/conf/sites-enabled/*;
|
||||
}
|
172
config/pgbouncer.conf
Normal file
172
config/pgbouncer.conf
Normal file
|
@ -0,0 +1,172 @@
|
|||
; database name = connect string
|
||||
[databases]
|
||||
|
||||
newsblur = host=db01 port=5433 dbname=newsblur
|
||||
|
||||
;; Configuation section
|
||||
[pgbouncer]
|
||||
|
||||
;;;
|
||||
;;; Administrative settings
|
||||
;;;
|
||||
|
||||
logfile = /var/log/postgresql/pgbouncer.log
|
||||
pidfile = /var/run/postgresql/pgbouncer.pid
|
||||
|
||||
;;;
|
||||
;;; Where to wait for clients
|
||||
;;;
|
||||
|
||||
; ip address or * which means all ip-s
|
||||
listen_addr = 127.0.0.1
|
||||
listen_port = 6432
|
||||
unix_socket_dir = /var/run/postgresql
|
||||
|
||||
;;;
|
||||
;;; Authentication settings
|
||||
;;;
|
||||
|
||||
; any, trust, plain, crypt, md5
|
||||
auth_type = trust
|
||||
; auth_file = 8.0/main/global/pg_auth
|
||||
auth_file = /etc/pgbouncer/userlist.txt
|
||||
|
||||
;;;
|
||||
;;; Users allowed into database 'pgbouncer'
|
||||
;;;
|
||||
|
||||
; comma-separated list of users, who are allowed to change settings
|
||||
admin_users =
|
||||
|
||||
; comma-separated list of users who are just allowed to use SHOW command
|
||||
stats_users =
|
||||
|
||||
;;;
|
||||
;;; Pooler personality questions
|
||||
;;;
|
||||
|
||||
; When server connection is released back to pool:
|
||||
; session - after client disconnects
|
||||
; transaction - after transaction finishes
|
||||
; statement - after statement finishes
|
||||
pool_mode = session
|
||||
|
||||
;
|
||||
; Query for cleaning connection immidiately after releasing from client.
|
||||
;
|
||||
; Query for 8.3+:
|
||||
; DISCARD ALL;
|
||||
;
|
||||
; Older versions:
|
||||
; RESET ALL; SET SESSION AUTHORIZATION DEFAULT
|
||||
;
|
||||
server_reset_query =
|
||||
|
||||
;
|
||||
; Comma-separated list of parameters to ignore when given
|
||||
; in startup packet. Newer JDBC versions require the
|
||||
; extra_float_digits here.
|
||||
;
|
||||
;ignore_startup_parameters = extra_float_digits
|
||||
|
||||
;
|
||||
; When taking idle server into use, this query is ran first.
|
||||
; SELECT 1
|
||||
;
|
||||
server_check_query = select 1
|
||||
|
||||
; If server was used more recently that this many seconds ago,
|
||||
; skip the check query. Value 0 may or may not run in immidiately.
|
||||
server_check_delay = 10
|
||||
|
||||
;;;
|
||||
;;; Connection limits
|
||||
;;;
|
||||
|
||||
; total number of clients that can connect
|
||||
max_client_conn = 100
|
||||
default_pool_size = 20
|
||||
|
||||
; how many additional connection to allow in case of trouble
|
||||
;reserve_pool_size = 5
|
||||
|
||||
; if a clients needs to wait more than this many seconds, use reserve pool
|
||||
;reserve_pool_timeout = 3
|
||||
|
||||
log_connections = 1
|
||||
log_disconnections = 1
|
||||
|
||||
; log error messages pooler sends to clients
|
||||
log_pooler_errors = 1
|
||||
|
||||
|
||||
; If off, then server connections are reused in LIFO manner
|
||||
;server_round_robin = 0
|
||||
|
||||
;;;
|
||||
;;; Timeouts
|
||||
;;;
|
||||
|
||||
;; Close server connection if its been connected longer.
|
||||
;server_lifetime = 1200
|
||||
|
||||
;; Close server connection if its not been used in this time.
|
||||
;; Allows to clean unneccessary connections from pool after peak.
|
||||
;server_idle_timeout = 60
|
||||
|
||||
;; Cancel connection attepmt if server does not answer takes longer.
|
||||
;server_connect_timeout = 15
|
||||
|
||||
;; If server login failed (server_connect_timeout or auth failure)
|
||||
;; then wait this many second.
|
||||
;server_login_retry = 15
|
||||
|
||||
;; Dangerous. Server connection is closed if query does not return
|
||||
;; in this time. Should be used to survive network problems,
|
||||
;; _not_ as statement_timeout. (default: 0)
|
||||
;query_timeout = 0
|
||||
|
||||
;; Dangerous. Client connection is closed if no activity in this time.
|
||||
;; Should be used to survive network problems. (default: 0)
|
||||
;client_idle_timeout = 0
|
||||
|
||||
;; Disconnect clients who have not managed to log in after connecting
|
||||
;; in this many seconds.
|
||||
;client_login_timeout = 60
|
||||
|
||||
;; Clean automatically created database entries (via "*") if they
|
||||
;; stay unused in this many seconds.
|
||||
; autodb_idle_timeout = 3600
|
||||
|
||||
;;;
|
||||
;;; Low-level tuning options
|
||||
;;;
|
||||
|
||||
;; buffer for streaming packets
|
||||
;pkt_buf = 2048
|
||||
|
||||
;; networking options, for info: man 7 tcp
|
||||
|
||||
;; linux: notify program about new connection only if there
|
||||
;; is also data received. (Seconds to wait.)
|
||||
;; On Linux the default is 45, on other OS'es 0.
|
||||
;tcp_defer_accept = 0
|
||||
|
||||
;; In-kernel buffer size (linux default: 4096)
|
||||
;tcp_socket_buffer = 0
|
||||
|
||||
;; whether tcp keepalive should be turned on (0/1)
|
||||
;tcp_keepalive = 0
|
||||
|
||||
;; following options are linux-specific.
|
||||
;; they also require tcp_keepalive=1
|
||||
|
||||
;; count of keepaliva packets
|
||||
;tcp_keepcnt = 0
|
||||
|
||||
;; how long the connection can be idle,
|
||||
;; before sending keepalive packets
|
||||
;tcp_keepidle = 0
|
||||
|
||||
;; The time between individual keepalive probes.
|
||||
;tcp_keepintvl = 0
|
47
config/staging.conf
Normal file
47
config/staging.conf
Normal file
|
@ -0,0 +1,47 @@
|
|||
upstream staging_server {
|
||||
server 127.0.0.1:9000 fail_timeout=1;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
client_max_body_size 4G;
|
||||
server_name dev.newsblur.com;
|
||||
|
||||
if (-f /home/conesus/staging/media/maintenance.html) {
|
||||
rewrite ^(.*) http://www.newsblur.com;
|
||||
break;
|
||||
}
|
||||
|
||||
location /media/admin/ {
|
||||
alias /usr/local/lib/python2.6/dist-packages/django/django/contrib/admin/media/;
|
||||
}
|
||||
location /media/ {
|
||||
expires max;
|
||||
root /home/conesus/staging;
|
||||
}
|
||||
location /favicon.ico {
|
||||
alias /home/conesus/staging/media/img/favicon.png;
|
||||
expires max;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ^~ /crossdomain.xml {
|
||||
expires max;
|
||||
alias /home/conesus/staging/media/crossdomain.xml;
|
||||
types {
|
||||
text/x-cross-domain-policy xml;
|
||||
}
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_redirect off;
|
||||
|
||||
if (!-f $request_filename) {
|
||||
proxy_pass http://staging_server;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
10
config/supervisor_gunicorn.conf
Normal file
10
config/supervisor_gunicorn.conf
Normal file
|
@ -0,0 +1,10 @@
|
|||
[program:gunicorn]
|
||||
#command=/home/conesus/newsblur/manage.py run_gunicorn -c gunicorn_conf.py
|
||||
command=gunicorn_django -c gunicorn_conf.py
|
||||
directory=/home/conesus/newsblur
|
||||
user=conesus
|
||||
autostart=true
|
||||
autorestart=true
|
||||
#redirect_stderr=True
|
||||
priority=991
|
||||
stopsignal=HUP
|
14
config/toprc
Normal file
14
config/toprc
Normal file
|
@ -0,0 +1,14 @@
|
|||
RCfile for "top with windows" # shameless braggin'
|
||||
Id:a, Mode_altscr=1, Mode_irixps=1, Delay_time=1.000, Curwin=0
|
||||
Def fieldscur=AEhiqtoWKNbMcdfgjprsluvyzX
|
||||
winflags=32184, sortindx=13, maxtasks=20
|
||||
summclr=1, msgsclr=1, headclr=3, taskclr=1
|
||||
Job fieldscur=ABcefgjlrstuvyzMKNHIWOPQDX
|
||||
winflags=65337, sortindx=10, maxtasks=0
|
||||
summclr=6, msgsclr=6, headclr=7, taskclr=6
|
||||
Mem fieldscur=ANOPQRSTUVbcdefgjlMyzWHIKX
|
||||
winflags=65337, sortindx=12, maxtasks=0
|
||||
summclr=5, msgsclr=5, headclr=4, taskclr=5
|
||||
Usr fieldscur=ABDECGfhijloPqrstuvyzMKNWX
|
||||
winflags=65400, sortindx=15, maxtasks=10
|
||||
summclr=3, msgsclr=3, headclr=2, taskclr=3
|
45
config/zshrc
Normal file
45
config/zshrc
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Path to your oh-my-zsh configuration.
|
||||
export ZSH=$HOME/.oh-my-zsh
|
||||
|
||||
# Set to the name theme to load.
|
||||
# Look in ~/.oh-my-zsh/themes/
|
||||
export ZSH_THEME="risto"
|
||||
|
||||
# Set to this to use case-sensitive completion
|
||||
export CASE_SENSITIVE="true"
|
||||
export LC_COLLATE='C'
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
export PROMPT='%{$fg_bold[green]%}%n@%M:%{$fg_bold[blue]%}%~ $(git_prompt_info)%{$reset_color%}%(!.#.$) '
|
||||
|
||||
export LSCOLORS='gxgxcxdxBxegedabagacad'
|
||||
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
||||
zstyle ':completion:*' list-colors "=(#b) #([0-9]#)*=36=31"
|
||||
setopt COMPLETE_IN_WORD
|
||||
# Don't complete stuff already on the line
|
||||
zstyle ':completion::*:(rm|vi):*' ignore-line true
|
||||
# Don't complete directory we are already in (../here)
|
||||
zstyle ':completion:*' ignore-parents parent pwd
|
||||
zstyle ':completion::approximate*:*' prefix-needed false
|
||||
|
||||
expand-or-complete-with-dots() {
|
||||
echo -n "\e[31m......\e[0m"
|
||||
zle expand-or-complete
|
||||
zle redisplay
|
||||
}
|
||||
zle -N expand-or-complete-with-dots
|
||||
bindkey "^I" expand-or-complete-with-dots
|
||||
unsetopt LIST_BEEP
|
||||
|
||||
# Customize to your needs...
|
||||
alias ls='ls -pFa --color'
|
||||
alias cd..='cd ..'
|
||||
|
||||
alias smtp='python -m smtpd -n -c DebuggingServer 127.0.0.1:1025'
|
||||
alias krf='ps ax | grep refresh_feeds | awk "{print $1}" | xargs kill -9'
|
||||
alias tlnb='echo "----------------\n"; tail -f logs/newsblur.log'
|
||||
alias cdsg='cd /home/conesus/staging'
|
||||
alias cdnb='cd /home/conesus/newsblur'
|
||||
|
||||
cd /home/conesus/newsblur
|
93
fabfile.py
vendored
93
fabfile.py
vendored
|
@ -97,16 +97,99 @@ def backup_postgresql():
|
|||
# = Bootstrap =
|
||||
# =============
|
||||
|
||||
def setup():
|
||||
env.user = 'root'
|
||||
setup_user()
|
||||
def setup_app():
|
||||
setup_common()
|
||||
setup_gunicorn()
|
||||
update_gunicorn()
|
||||
setup_nginx()
|
||||
|
||||
def setup_db():
|
||||
setup_postgres()
|
||||
|
||||
def setup_task():
|
||||
setup_celery()
|
||||
|
||||
def setup_common():
|
||||
setup_installs()
|
||||
# setup_user()
|
||||
setup_server()
|
||||
setup_repo()
|
||||
setup_python()
|
||||
setup_libxml()
|
||||
setup_mongoengine()
|
||||
setup_supervisor()
|
||||
|
||||
def setup_user():
|
||||
run('useradd conesus ')
|
||||
run('useradd -c "NewsBlur" -m conesus -s /bin/zsh')
|
||||
run('openssl rand -base64 8 | tee -a ~conesus/.password | passwd -stdin conesus')
|
||||
run('mkdir ~conesus/.ssh && chmod 700 ~conesus/.ssh')
|
||||
|
||||
def setup_server():
|
||||
sudo('hostname app02')
|
||||
|
||||
def setup_installs():
|
||||
run('apt-get -y install sysstat git')
|
||||
sudo('apt-get -y update')
|
||||
sudo('apt-get -y upgrade')
|
||||
sudo('apt-get -y install gcc sysstat git zsh python-dev locate python-software-properties libpcre3-dev libssl-dev make pgbouncer python-psycopg2 libmemcache0 memcached python-memcache libyaml-0-2 python-yaml python-numpy python-scipy python-imaging')
|
||||
sudo('add-apt-repository ppa:pitti/postgresql')
|
||||
sudo('apt-get -y update')
|
||||
sudo('apt-get -y install postgresql-client-9.0')
|
||||
run('git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh')
|
||||
run('curl -O http://peak.telecommunity.com/dist/ez_setup.py')
|
||||
sudo('python ez_setup.py -U setuptools && rm ez_setup.py')
|
||||
|
||||
def setup_repo():
|
||||
run('mkdir -p ~/code')
|
||||
run('git clone https://github.com/samuelclay/NewsBlur.git newsblur')
|
||||
with cd('~/newsblur'):
|
||||
run('cp local_settings.py.template local_settings.py')
|
||||
run('mkdir -p logs')
|
||||
|
||||
def setup_python():
|
||||
sudo('easy_install pip')
|
||||
sudo('easy_install django django-celery django-compress South django-devserver django-extensions guppy psycopg2 BeautifulSoup pyyaml nltk lxml oauth2 pytz boto')
|
||||
sudo('su -c \'echo "import sys; sys.setdefaultencoding(\"utf-8\")" > /usr/lib/python2.6/sitecustomize.py\'')
|
||||
|
||||
def setup_libxml():
|
||||
sudo('apt-get -y install libxml2-dev libxslt1-dev python-lxml')
|
||||
# with cd('~/code'):
|
||||
# run('git clone git://git.gnome.org/libxml2')
|
||||
# run('git clone git://git.gnome.org/libxslt')
|
||||
#
|
||||
# with cd('~/code/libxml2'):
|
||||
# run('./configure && make && sudo make install')
|
||||
#
|
||||
# with cd('~/code/libxslt'):
|
||||
# run('./configure && make && sudo make install')
|
||||
|
||||
def setup_gunicorn():
|
||||
with cd('~/code'):
|
||||
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'):
|
||||
run('git pull')
|
||||
sudo('python setup.py install')
|
||||
|
||||
def setup_nginx():
|
||||
with cd('~/code'):
|
||||
run('wget http://sysoev.ru/nginx/nginx-0.9.4.tar.gz')
|
||||
run('tar -xzf nginx-0.9.4.tar.gz')
|
||||
run('rm nginx-0.9.4.tar.gz')
|
||||
with cd('~/code/nginx-0.9.4'):
|
||||
run('./configure --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module')
|
||||
run('make')
|
||||
run('sudo make isntall')
|
||||
|
||||
def setup_mongoengine():
|
||||
with cd('~/code'):
|
||||
run('https://github.com/hmarr/mongoengine.git')
|
||||
sudo('ln -s ~/code/mongoengine/mongoengine /usr/local/lib/python2.6/dist-packages/mongoengine')
|
||||
|
||||
def setup_supervisor():
|
||||
sudo('apt-get -y install supervisor')
|
||||
|
||||
|
||||
# ======
|
||||
# = S3 =
|
||||
|
|
|
@ -4119,10 +4119,10 @@
|
|||
|
||||
if (feed_id == this.active_feed) {
|
||||
NEWSBLUR.log(['UPDATING INLINE', feed.feed_title, $feed, $feed_on_page]);
|
||||
// var limit = $('.story', this.$s.$story_titles).length;
|
||||
// this.model.refresh_feed(feed_id, $.rescope(this.post_refresh_active_feed, this), limit);
|
||||
// $feed_on_page.replaceWith($feed);
|
||||
// this.mark_feed_as_selected(this.active_feed, $feed);
|
||||
var limit = $('.story', this.$s.$story_titles).length;
|
||||
this.model.refresh_feed(feed_id, $.rescope(this.post_refresh_active_feed, this), limit);
|
||||
$feed_on_page.replaceWith($feed);
|
||||
this.mark_feed_as_selected(this.active_feed, $feed);
|
||||
} else {
|
||||
if (!this.flags['has_unfetched_feeds']) {
|
||||
NEWSBLUR.log(['UPDATING', feed.feed_title, $feed, $feed_on_page]);
|
||||
|
|
Loading…
Add table
Reference in a new issue