mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Merge branch 'master' into offline
* master: Preparing for PostgreSQL server migration. Adding postgres apt script. Refacotring node+work servers out of app servers. Fixing auto bootstraps. Also splitting favicons onto its own server.
This commit is contained in:
commit
7625251c22
10 changed files with 194 additions and 45 deletions
|
@ -41,24 +41,27 @@ frontend public
|
|||
monitor fail if gunicorn_dead
|
||||
monitor fail if nginx_dead
|
||||
monitor fail if mx_mode
|
||||
|
||||
use_backend node if { path_beg /socket.io/ }
|
||||
|
||||
use_backend node_socket if { path_beg /socket.io/ }
|
||||
use_backend node_favicon if { path_beg /rss_feeds/icon }
|
||||
use_backend nginx if { path_beg /media/ }
|
||||
use_backend nginx if { path_beg /static/ }
|
||||
use_backend nginx if { path_beg /favicon }
|
||||
use_backend nginx if { path_beg /crossdomain/ }
|
||||
use_backend nginx if { path_beg /robots }
|
||||
use_backend nginx if { path_beg /munin/ }
|
||||
use_backend nginx if { path_beg /rss_feeds/icon }
|
||||
|
||||
use_backend nginx if mx_mode
|
||||
|
||||
use_backend gunicorn unless gunicorn_dead || nginx_dead
|
||||
|
||||
backend node
|
||||
backend node_socket
|
||||
balance roundrobin
|
||||
server nodedebug 127.0.0.1:8888 check inter 2000ms
|
||||
|
||||
backend node_favicon
|
||||
balance roundrobin
|
||||
server nodedebug 127.0.0.1:81 check inter 2000ms
|
||||
|
||||
backend nginx
|
||||
balance roundrobin
|
||||
|
|
|
@ -16,7 +16,7 @@ logappend=true
|
|||
|
||||
slowms=100
|
||||
|
||||
syncdelay=5
|
||||
syncdelay=15
|
||||
|
||||
rest = true
|
||||
#profile = 2
|
||||
|
|
|
@ -91,11 +91,11 @@ server {
|
|||
}
|
||||
|
||||
location /munin/ {
|
||||
# alias /var/cache/munin/www/;
|
||||
fastcgi_split_path_info ^(/munin)(.*);
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_pass unix:/var/run/munin/fcgi-html.sock;
|
||||
include fastcgi_params;
|
||||
alias /var/cache/munin/www/;
|
||||
# fastcgi_split_path_info ^(/munin)(.*);
|
||||
# fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
# fastcgi_pass unix:/var/run/munin/fcgi-html.sock;
|
||||
# include fastcgi_params;
|
||||
}
|
||||
|
||||
location ^~ /cgi-bin/munin-cgi-graph/ {
|
||||
|
|
136
config/postgres_apt.sh
Executable file
136
config/postgres_apt.sh
Executable file
|
@ -0,0 +1,136 @@
|
|||
#!/bin/sh
|
||||
|
||||
# script to add apt.postgresql.org to sources.list
|
||||
|
||||
# from command like
|
||||
CODENAME="$1"
|
||||
# lsb_release is the best interface, but not always available
|
||||
if [ -z "$CODENAME" ]; then
|
||||
CODENAME=$(lsb_release -cs 2>/dev/null)
|
||||
fi
|
||||
# parse os-release (unreliable, does not work on Ubuntu)
|
||||
if [ -z "$CODENAME" -a -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
# Debian: VERSION="7.0 (wheezy)"
|
||||
# Ubuntu: VERSION="13.04, Raring Ringtail"
|
||||
CODENAME=$(echo $VERSION | sed -ne 's/.*(\(.*\)).*/\1/')
|
||||
fi
|
||||
# guess from sources.list
|
||||
if [ -z "$CODENAME" ]; then
|
||||
CODENAME=$(grep '^deb ' /etc/apt/sources.list | head -n1 | awk '{ print $3 }')
|
||||
fi
|
||||
# complain if no result yet
|
||||
if [ -z "$CODENAME" ]; then
|
||||
cat <<EOF
|
||||
Could not determine the distribution codename. Please report this as a bug to
|
||||
pgsql-pkg-debian@postgresql.org. As a workaround, you can call this script with
|
||||
the proper codename as parameter, e.g. "$0 squeeze".
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# errors are non-fatal above
|
||||
set -e
|
||||
|
||||
cat <<EOF
|
||||
This script will enable the PostgreSQL APT repository on apt.postgresql.org on
|
||||
your system. The distribution codename used will be $CODENAME-pgdg.
|
||||
|
||||
EOF
|
||||
|
||||
case $CODENAME in
|
||||
# known distributions
|
||||
sid|wheezy|squeeze|lenny|etch) ;;
|
||||
precise|lucid) ;;
|
||||
*) # unknown distribution, verify on the web
|
||||
DISTURL="http://apt.postgresql.org/pub/repos/apt/dists/"
|
||||
if [ -x /usr/bin/curl ]; then
|
||||
DISTHTML=$(curl -s $DISTURL)
|
||||
elif [ -x /usr/bin/wget ]; then
|
||||
DISTHTML=$(wget --quiet -O - $DISTURL)
|
||||
fi
|
||||
if [ "$DISTHTML" ]; then
|
||||
if ! echo "$DISTHTML" | grep -q "$CODENAME-pgdg"; then
|
||||
cat <<EOF
|
||||
Your system is using the distribution codename $CODENAME, but $CODENAME-pgdg
|
||||
does not seem to be a valid distribution on
|
||||
$DISTURL
|
||||
|
||||
We abort the installation here. Please ask on the mailing list for assistance.
|
||||
|
||||
pgsql-pkg-debian@postgresql.org
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo -n "Press Enter to continue, or Ctrl-C to abort."
|
||||
|
||||
read enter
|
||||
|
||||
echo "Writing /etc/apt/sources.list.d/pgdg.list ..."
|
||||
cat > /etc/apt/sources.list.d/pgdg.list <<EOF
|
||||
deb http://apt.postgresql.org/pub/repos/apt/ $CODENAME-pgdg main
|
||||
#deb-src http://apt.postgresql.org/pub/repos/apt/ $CODENAME-pgdg main
|
||||
EOF
|
||||
|
||||
echo "Importing repository signing key ..."
|
||||
KEYRING="/etc/apt/trusted.gpg.d/apt.postgresql.org.gpg"
|
||||
test -e $KEYRING || touch $KEYRING
|
||||
apt-key --keyring $KEYRING add - <<EOF
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.4.12 (GNU/Linux)
|
||||
|
||||
mQINBE6XR8IBEACVdDKT2HEH1IyHzXkb4nIWAY7echjRxo7MTcj4vbXAyBKOfjja
|
||||
UrBEJWHN6fjKJXOYWXHLIYg0hOGeW9qcSiaa1/rYIbOzjfGfhE4x0Y+NJHS1db0V
|
||||
G6GUj3qXaeyqIJ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RZCc5YVmeAo91qIzI/tA2gtXik49
|
||||
6yeziZbfUvcZzuzjjxFExss4DSAwMgorvBeIbiz2k2qXukbqcTjB2XqAlZasd6Ll
|
||||
nLXpQdqDV3McYkP/MvttWh3w+J/woiBcA7yEI5e3YJk97uS6+ssbqLEd0CcdT+qz
|
||||
+Waw0z/ZIU99Lfh2Qm77OT6vr//Zulw5ovjZVO2boRIcve7S97gQ4KC+G/+QaRS+
|
||||
VPZ67j5UMxqtT/Y4+NHcQGgwF/1i
|
||||
=Iugu
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
EOF
|
||||
|
||||
echo "Running apt-get update ..."
|
||||
apt-get update
|
||||
|
||||
cat <<EOF
|
||||
|
||||
You can now start installing packages from apt.postgresql.org.
|
||||
|
||||
Have a look at https://wiki.postgresql.org/wiki/Apt for more information;
|
||||
most notably the FAQ at https://wiki.postgresql.org/wiki/Apt/FAQ
|
||||
EOF
|
|
@ -392,7 +392,7 @@ log_line_prefix = '%t %h' # special values:
|
|||
# - Query/Index Statistics Collector -
|
||||
|
||||
#track_activities = on
|
||||
#track_counts = on
|
||||
track_counts = on
|
||||
#track_functions = none # none, pl, all
|
||||
#track_activity_query_size = 1024 # (change requires restart)
|
||||
#update_process_title = on
|
||||
|
|
|
@ -6,15 +6,15 @@ standby_mode = 'on'
|
|||
|
||||
# Specifies a connection string which is used for the standby server to connect
|
||||
# with the primary.
|
||||
primary_conninfo = 'host=db01 port=5432 user=postgres'
|
||||
primary_conninfo = 'host=db11 port=5432 user=postgres'
|
||||
|
||||
# Specifies a trigger file whose presence should cause streaming replication to
|
||||
# end (i.e., failover).
|
||||
trigger_file = '/var/lib/postgresql/9.1/main/standby.trigger'
|
||||
trigger_file = '/var/lib/postgresql/9.2/main/standby.trigger'
|
||||
|
||||
# Specifies a command to load archive segments from the WAL archive. If
|
||||
# wal_keep_segments is a high enough number to retain the WAL segments
|
||||
# required for the standby server, this may not be necessary. But
|
||||
# a large workload can cause segments to be recycled before the standby
|
||||
# is fully synchronized, requiring you to start again from a new base backup.
|
||||
restore_command = 'rsync -a db01:/var/lib/postgresql/9.1/archive/%f "%p"'
|
||||
restore_command = 'rsync -a db11:/var/lib/postgresql/9.2/archive/%f "%p"'
|
||||
|
|
|
@ -38,15 +38,15 @@
|
|||
# The default values of these variables are driven from the -D command-line
|
||||
# option or PGDATA environment variable, represented here as ConfigDir.
|
||||
|
||||
data_directory = '/var/lib/postgresql/9.1/main' # use data in another directory
|
||||
data_directory = '/var/lib/postgresql/9.2/main' # use data in another directory
|
||||
# (change requires restart)
|
||||
hba_file = '/etc/postgresql/9.1/main/pg_hba.conf' # host-based authentication file
|
||||
hba_file = '/etc/postgresql/9.2/main/pg_hba.conf' # host-based authentication file
|
||||
# (change requires restart)
|
||||
ident_file = '/etc/postgresql/9.1/main/pg_ident.conf' # ident configuration file
|
||||
ident_file = '/etc/postgresql/9.2/main/pg_ident.conf' # ident configuration file
|
||||
# (change requires restart)
|
||||
|
||||
# If external_pid_file is not explicitly set, no extra PID file is written.
|
||||
external_pid_file = '/var/run/postgresql/9.1-main.pid' # write an extra PID file
|
||||
external_pid_file = '/var/run/postgresql/9.2-main.pid' # write an extra PID file
|
||||
# (change requires restart)
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ listen_addresses = '*' # what IP address(es) to listen on;
|
|||
# defaults to 'localhost', '*' = all
|
||||
# (change requires restart)
|
||||
port = 5432 # (change requires restart)
|
||||
max_connections = 200 # (change requires restart)
|
||||
max_connections = 1000 # (change requires restart)
|
||||
# Note: Increasing max_connections costs ~400 bytes of shared memory per
|
||||
# connection slot, plus lock space (see max_locks_per_transaction).
|
||||
#superuser_reserved_connections = 3 # (change requires restart)
|
||||
|
@ -77,7 +77,7 @@ unix_socket_directory = '/var/run/postgresql' # (change requires restart)
|
|||
# - Security and Authentication -
|
||||
|
||||
#authentication_timeout = 1min # 1s-600s
|
||||
ssl = true # (change requires restart)
|
||||
ssl = false # (change requires restart)
|
||||
#ssl_ciphers = 'ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers
|
||||
# (change requires restart)
|
||||
#ssl_renegotiation_limit = 512MB # amount of data between renegotiations
|
||||
|
@ -392,7 +392,7 @@ log_line_prefix = '%t %h' # special values:
|
|||
# - Query/Index Statistics Collector -
|
||||
|
||||
#track_activities = on
|
||||
#track_counts = on
|
||||
track_counts = on
|
||||
#track_functions = none # none, pl, all
|
||||
#track_activity_query_size = 1024 # (change requires restart)
|
||||
#update_process_title = on
|
||||
|
@ -411,7 +411,7 @@ log_line_prefix = '%t %h' # special values:
|
|||
# AUTOVACUUM PARAMETERS
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
#autovacuum = on # Enable autovacuum subprocess? 'on'
|
||||
autovacuum = on # Enable autovacuum subprocess? 'on'
|
||||
# requires track_counts to also be on.
|
||||
#log_autovacuum_min_duration = -1 # -1 disables, 0 logs all actions and
|
||||
# their durations, > 0 logs only
|
||||
|
|
|
@ -8,7 +8,7 @@ chmod=0700 ; sockef file mode (default 0700)
|
|||
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
|
||||
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
|
||||
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
|
||||
minfds = 10000
|
||||
# minfds = 10000
|
||||
|
||||
; the below section must remain in the config file for RPC
|
||||
; (supervisorctl/web interface) to work, additional interfaces may be
|
||||
|
|
52
fabfile.py
vendored
52
fabfile.py
vendored
|
@ -110,6 +110,10 @@ def app():
|
|||
do()
|
||||
env.roles = ['app']
|
||||
|
||||
def web():
|
||||
do()
|
||||
env.roles = ['app', 'push', 'work']
|
||||
|
||||
def work():
|
||||
do()
|
||||
env.roles = ['work']
|
||||
|
@ -149,7 +153,7 @@ def ec2():
|
|||
|
||||
def all():
|
||||
do()
|
||||
env.roles = ['app', 'dev', 'db', 'task', 'debug', 'node', 'push']
|
||||
env.roles = ['app', 'dev', 'db', 'task', 'debug', 'node', 'push', 'work']
|
||||
|
||||
# =============
|
||||
# = Bootstrap =
|
||||
|
@ -192,16 +196,20 @@ def setup_app(skip_common=False):
|
|||
setup_app_firewall()
|
||||
setup_app_motd()
|
||||
copy_app_settings()
|
||||
configure_nginx()
|
||||
config_nginx()
|
||||
setup_gunicorn(supervisor=True)
|
||||
update_gunicorn()
|
||||
setup_node()
|
||||
configure_node()
|
||||
# setup_node_app()
|
||||
# config_node()
|
||||
pre_deploy()
|
||||
deploy()
|
||||
deploy_web()
|
||||
config_monit_app()
|
||||
done()
|
||||
|
||||
def setup_node():
|
||||
setup_node_app()
|
||||
config_node()
|
||||
|
||||
def setup_db(engine=None, skip_common=False):
|
||||
if not skip_common:
|
||||
setup_common()
|
||||
|
@ -245,8 +253,8 @@ def setup_task(queue=None, skip_common=False):
|
|||
|
||||
def setup_installs():
|
||||
sudo('apt-get -y update')
|
||||
sudo('apt-get -y upgrade')
|
||||
sudo('apt-get -y install build-essential gcc scons libreadline-dev sysstat iotop git python-dev locate python-software-properties software-properties-common libpcre3-dev libncurses5-dev libdbd-pg-perl libssl-dev make pgbouncer python-setuptools python-psycopg2 libyaml-0-2 python-yaml python-numpy python-scipy curl monit ufw libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev python-imaging')
|
||||
sudo('DEBIAN_FRONTEND=noninteractive apt-get -y upgrade')
|
||||
sudo('DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential gcc scons libreadline-dev sysstat iotop git python-dev locate python-software-properties software-properties-common libpcre3-dev libncurses5-dev libdbd-pg-perl libssl-dev make pgbouncer python-setuptools python-psycopg2 libyaml-0-2 python-yaml python-numpy python-scipy curl monit ufw libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev python-imaging')
|
||||
|
||||
sudo("ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib")
|
||||
sudo("ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib")
|
||||
|
@ -346,6 +354,7 @@ def setup_python():
|
|||
with settings(warn_only=True):
|
||||
sudo('su -c \'echo "import sys; sys.setdefaultencoding(\\\\"utf-8\\\\")" > /usr/lib/python2.7/sitecustomize.py\'')
|
||||
sudo("chmod a+r /usr/local/lib/python2.7/dist-packages/httplib2-0.8-py2.7.egg/EGG-INFO/top_level.txt")
|
||||
sudo("chmod a+r /usr/local/lib/python2.7/dist-packages/python_dateutil-2.1-py2.7.egg/EGG-INFO/top_level.txt")
|
||||
|
||||
if env.user == 'ubuntu':
|
||||
with settings(warn_only=True):
|
||||
|
@ -488,9 +497,9 @@ def setup_nginx():
|
|||
run('./configure --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module')
|
||||
run('make')
|
||||
sudo('make install')
|
||||
configure_nginx()
|
||||
config_nginx()
|
||||
|
||||
def configure_nginx():
|
||||
def config_nginx():
|
||||
put("config/nginx.conf", "/usr/local/nginx/conf/nginx.conf", use_sudo=True)
|
||||
sudo("mkdir -p /usr/local/nginx/conf/sites-enabled")
|
||||
sudo("mkdir -p /var/log/nginx")
|
||||
|
@ -542,7 +551,7 @@ def setup_staging():
|
|||
run('mkdir -p logs')
|
||||
run('touch logs/newsblur.log')
|
||||
|
||||
def setup_node():
|
||||
def setup_node_app():
|
||||
sudo('add-apt-repository -y ppa:chris-lea/node.js')
|
||||
sudo('apt-get update')
|
||||
sudo('apt-get install -y nodejs')
|
||||
|
@ -550,7 +559,7 @@ def setup_node():
|
|||
sudo('npm install -g supervisor')
|
||||
sudo('ufw allow 8888')
|
||||
|
||||
def configure_node():
|
||||
def config_node():
|
||||
sudo('rm -fr /etc/supervisor/conf.d/node.conf')
|
||||
put('config/supervisor_node_unread.conf', '/etc/supervisor/conf.d/node_unread.conf', use_sudo=True)
|
||||
# put('config/supervisor_node_unread_ssl.conf', '/etc/supervisor/conf.d/node_unread_ssl.conf', use_sudo=True)
|
||||
|
@ -704,16 +713,17 @@ def setup_rabbitmq():
|
|||
# sudo('apt-get -y install memcached')
|
||||
|
||||
def setup_postgres(standby=False):
|
||||
# shmmax = 2300047872
|
||||
sudo('add-apt-repository ppa:pitti/postgresql')
|
||||
shmmax = 2300047872
|
||||
# sudo('su root -c "echo \\\"deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main\\\" > /etc/apt/sources.list.d/pgdg.list\"')
|
||||
sudo('wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -')
|
||||
sudo('apt-get update')
|
||||
sudo('apt-get -y install postgresql-9.2 postgresql-client postgresql-contrib libpq-dev')
|
||||
put('config/postgresql%s.conf' % (
|
||||
('_standby' if standby else ''),
|
||||
), '/etc/postgresql/9.2/main/postgresql.conf', use_sudo=True)
|
||||
# sudo('echo "%s" > /proc/sys/kernel/shmmax' % shmmax)
|
||||
# sudo('echo "\nkernel.shmmax = %s" > /etc/sysctl.conf' % shmmax)
|
||||
# sudo('sysctl -p')
|
||||
sudo('echo "%s" > /proc/sys/kernel/shmmax' % shmmax)
|
||||
sudo('echo "\nkernel.shmmax = %s" > /etc/sysctl.conf' % shmmax)
|
||||
sudo('sysctl -p')
|
||||
|
||||
if standby:
|
||||
put('config/postgresql_recovery.conf', '/var/lib/postgresql/9.2/recovery.conf', use_sudo=True)
|
||||
|
@ -722,11 +732,11 @@ def setup_postgres(standby=False):
|
|||
sudo('/etc/init.d/postgresql start')
|
||||
|
||||
def copy_postgres_to_standby():
|
||||
slave = 'db13'
|
||||
slave = 'db01'
|
||||
# Make sure you can ssh from master to slave and back.
|
||||
# Need to give postgres accounts keys in authroized_keys.
|
||||
|
||||
# sudo('su postgres -c "psql -c \\"SELECT pg_start_backup(\'label\', true)\\""', pty=False)
|
||||
# sudo('su postgres -c "psql -c \"SELECT pg_start_backup(\'label\', true)\""', pty=False)
|
||||
sudo('su postgres -c \"rsync -a --stats --progress /var/lib/postgresql/9.2/main postgres@%s:/var/lib/postgresql/9.2/ --exclude postmaster.pid\"' % slave, pty=False)
|
||||
sudo('su postgres -c "psql -c \"SELECT pg_stop_backup()\""', pty=False)
|
||||
|
||||
|
@ -860,7 +870,7 @@ def setup_db_mdadm():
|
|||
sudo("sudo update-initramfs -u -v -k `uname -r`")
|
||||
|
||||
def setup_original_page_server():
|
||||
setup_node()
|
||||
setup_node_app()
|
||||
sudo('mkdir -p /srv/originals')
|
||||
sudo('chown %s.%s -R /srv/originals' % (env.user, env.user)) # We assume that the group is the same name as the user. It's common on linux
|
||||
put('config/supervisor_node_original.conf',
|
||||
|
@ -921,7 +931,7 @@ def copy_task_settings():
|
|||
|
||||
def setup_do(name, size=2):
|
||||
INSTANCE_SIZE = "%sGB" % size
|
||||
IMAGE_NAME = "Ubuntu 13.04 x64 Server"
|
||||
IMAGE_NAME = "Ubuntu 13.04 x64"
|
||||
doapi = dop.client.Client(django_settings.DO_CLIENT_KEY, django_settings.DO_API_KEY)
|
||||
sizes = dict((s.name, s.id) for s in doapi.sizes())
|
||||
size_id = sizes[INSTANCE_SIZE]
|
||||
|
@ -969,7 +979,7 @@ def do_name(name):
|
|||
hosts = do_roledefs(split=False)
|
||||
hostnames = [host.name for host in hosts]
|
||||
existing_hosts = [hostname for hostname in hostnames if name in hostname]
|
||||
for i in range(10, 50):
|
||||
for i in range(1, 50):
|
||||
try_host = "%s%02d" % (name, i)
|
||||
if try_host not in existing_hosts:
|
||||
print " ---> %s hosts in %s (%s). %s is unused." % (len(existing_hosts), name,
|
||||
|
|
|
@ -15,7 +15,7 @@ IGNORE_HOSTS = [
|
|||
'push',
|
||||
]
|
||||
|
||||
def main(role="app", role2="app", command=None, path=None):
|
||||
def main(role="app", role2="work", command=None, path=None):
|
||||
delay = 1
|
||||
|
||||
while True:
|
||||
|
|
Loading…
Add table
Reference in a new issue