airport: Update to work with new django1.5 version of airport.
* Only just python 3 * Update postgres dependency to 9.3 * Remove apache. Replace with nginx/uwsgi mix. * Don't double-install packages in both portage and virtualenv.
This commit is contained in:
parent
d4fa57eda3
commit
80bd6a3d83
|
@ -1,18 +1,13 @@
|
|||
APP_ROOT := /var/airport
|
||||
AIRPORT_REPO ?= https://bitbucket.org/marduk/airport
|
||||
PGVER := 9.2
|
||||
PGVER := 9.3
|
||||
|
||||
rcdefault := /etc/runlevels/default
|
||||
|
||||
preinstall:
|
||||
$(inroot) $(EMERGE) -n $(USEPKG) python:2.7
|
||||
$(inroot) eselect python set python2.7
|
||||
$(inroot) python-updater
|
||||
|
||||
|
||||
postinstall: airport.service settings.py airport.wsgi default_vhost.include firstboot.start issue
|
||||
sed -i 's/^APACHE2_OPTS=.*/APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D WSGI"/' $(CHROOT)/etc/conf.d/apache2
|
||||
$(inroot) rc-update add apache2 default
|
||||
postinstall: airport.service settings.py firstboot.start zzairport.start issue nginx.conf
|
||||
sed -i 's/^PG_INITDB_OPTS.*/PG_INITDB_OPTS="--locale=en_US.UTF-8"/' $(CHROOT)/etc/conf.d/postgresql-$(PGVER)
|
||||
$(inroot) eselect postgresql set $(PGVER)
|
||||
rm -rf $(CHROOT)/var/lib/postgresql/$(PGVER)
|
||||
|
@ -23,24 +18,26 @@ postinstall: airport.service settings.py airport.wsgi default_vhost.include firs
|
|||
rm -rf $(CHROOT)/$(APP_ROOT)
|
||||
hg clone $(AIRPORT_REPO) $(CHROOT)/$(APP_ROOT)
|
||||
echo 'VERSION="'`date +1.%y%m%d.%H%m`'"' > $(CHROOT)/$(APP_ROOT)/djangoproject/airport/__init__.py
|
||||
chroot $(CHROOT) virtualenv -p /usr/bin/python2.7 $(APP_ROOT)
|
||||
chroot $(CHROOT) virtualenv -p /usr/bin/python3.2 $(APP_ROOT)
|
||||
$(inroot) bash -c ". $(APP_ROOT)/bin/activate ; pip install -r $(APP_ROOT)/requirements.txt"
|
||||
$(inroot) bash -c ". $(APP_ROOT)/bin/activate ; pip install psycopg2"
|
||||
$(inroot) bash -c ". $(APP_ROOT)/bin/activate ; pip install psycopg2 uwsgi"
|
||||
mkdir -p $(CHROOT)/$(APP_ROOT)/etc
|
||||
touch $(CHROOT)/$(APP_ROOT)/etc/__init__.py
|
||||
cp settings.py $(CHROOT)/$(APP_ROOT)/etc
|
||||
cp default_vhost.include $(CHROOT)/etc/apache2/vhosts.d
|
||||
cp airport.wsgi $(CHROOT)/var/www/localhost
|
||||
$(inroot) id -u airport >/dev/null || $(inroot) useradd -d $(APP_ROOT) -M -s /bin/false -U -G postgres airport
|
||||
$(inroot) gpasswd -a apache postgres
|
||||
$(inroot) chown -R airport:airport $(APP_ROOT)
|
||||
cp firstboot.start $(CHROOT)/etc/local.d
|
||||
cp zzairport.start $(CHROOT)/etc/local.d
|
||||
cp issue $(CHROOT)/etc/issue
|
||||
$(M4) -D HOSTNAME=$(HOSTNAME) nginx.conf > $(CHROOT)/etc/nginx/nginx.conf
|
||||
$(inroot) ln -sf /etc/init.d/nginx $(rcdefault)/nginx
|
||||
ifeq ($(AVAHI),YES)
|
||||
$(inroot) $(EMERGE) -n $(USEPKG) net-dns/avahi
|
||||
$(inroot) rm -f /etc/avahi/services/*
|
||||
cp airport.service $(CHROOT)/etc/avahi/services
|
||||
$(inroot) ln -sf /etc/init.d/avahi-daemon $(rcdefault)/avahi-daemon
|
||||
endif
|
||||
$(inroot) $(EMERGE) --depclean --with-bdeps=n
|
||||
|
||||
|
||||
clean:
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
sys.stdout = sys.stderr
|
||||
|
||||
import site
|
||||
site.addsitedir('/var/airport/lib/python2.7/site-packages')
|
||||
|
||||
sys.path.append('/var/airport')
|
||||
sys.path.append('/var/airport/djangoproject')
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'etc.settings'
|
||||
os.environ['VIRTUAL_ENV'] = '/var/airport/'
|
||||
|
||||
import django.core.handlers.wsgi
|
||||
application = django.core.handlers.wsgi.WSGIHandler()
|
||||
|
||||
# vim: filetype=python
|
|
@ -1,24 +0,0 @@
|
|||
ServerAdmin root@localhost
|
||||
KeepAlive Off
|
||||
|
||||
DocumentRoot "/var/www/localhost/htdocs"
|
||||
|
||||
# This should be changed to whatever you set DocumentRoot to.
|
||||
<Directory "/var/www/localhost/htdocs">
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
|
||||
# Controls who can get stuff from this server.
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
|
||||
WSGIDaemonProcess airport display-name=airport user=airport processes=2 threads=15
|
||||
WSGISCriptAlias / /var/www/localhost/airport.wsgi
|
||||
<Directory />
|
||||
AllowOverride None
|
||||
Order Deny,Allow
|
||||
</Directory>
|
||||
|
||||
# vim: ts=4 filetype=apache
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
# Settings for Airport
|
||||
PYTHON_TARGETS="python2_7"
|
||||
APACHE2_MPMS="prefork"
|
||||
APACHE2_MODULES="auth_basic authz_host env include info"
|
||||
PYTHON_TARGETS="python3_2"
|
||||
USE_PYTHON="3.2"
|
||||
NGINX_MODULES_HTTP="auth_basic gzip proxy referer rewrite headers_more uwsgi"
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
user nginx nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error_log info;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
use epoll;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main
|
||||
'$remote_addr - $remote_user [$time_local] '
|
||||
'"$request" $status $bytes_sent '
|
||||
'"$http_referer" "$http_user_agent" '
|
||||
'"$gzip_ratio"';
|
||||
|
||||
client_header_timeout 10m;
|
||||
client_body_timeout 10m;
|
||||
send_timeout 10m;
|
||||
|
||||
connection_pool_size 256;
|
||||
client_header_buffer_size 1k;
|
||||
large_client_header_buffers 4 2k;
|
||||
request_pool_size 4k;
|
||||
|
||||
gzip on;
|
||||
gzip_min_length 1100;
|
||||
gzip_buffers 4 8k;
|
||||
gzip_types text/plain;
|
||||
|
||||
output_buffers 1 32k;
|
||||
postpone_output 1460;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
|
||||
keepalive_timeout 75 20;
|
||||
|
||||
ignore_invalid_headers on;
|
||||
|
||||
index index.html;
|
||||
|
||||
server {
|
||||
listen 0.0.0.0;
|
||||
server_name HOSTNAME;
|
||||
|
||||
location /static/ {
|
||||
alias /var/airport/djangoproject/airport/static/;
|
||||
}
|
||||
|
||||
location / {
|
||||
uwsgi_pass unix:///var/airport/airport.sock;
|
||||
include /etc/nginx/uwsgi_params;
|
||||
}
|
||||
|
||||
access_log /var/log/nginx/HOSTNAME.access_log main;
|
||||
error_log /var/log/nginx/HOSTNAME.error_log info;
|
||||
|
||||
root /var/www/localhost/htdocs;
|
||||
}
|
||||
|
||||
# SSL example
|
||||
#server {
|
||||
# listen 127.0.0.1:443;
|
||||
# server_name localhost;
|
||||
|
||||
# ssl on;
|
||||
# ssl_certificate /etc/ssl/nginx/nginx.pem;
|
||||
# ssl_certificate_key /etc/ssl/nginx/nginx.key;
|
||||
|
||||
# access_log /var/log/nginx/localhost.ssl_access_log main;
|
||||
# error_log /var/log/nginx/localhost.ssl_error_log info;
|
||||
|
||||
# root /var/www/localhost/htdocs;
|
||||
#}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
=dev-python/django-1.4* **
|
||||
dev-db/postgresql-base:9.2 **
|
||||
dev-db/postgresql-server:9.2 **
|
||||
dev-db/postgresql-base:9.3 **
|
||||
dev-db/postgresql-server:9.3 **
|
||||
sys-kernel/gentoo-sources ~amd64 ~x86
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
app-editors/nano ncurses
|
||||
dev-lang/python ssl threads xml
|
||||
dev-libs/libpcre cxx
|
||||
net-misc/dhcp client
|
||||
sys-apps/kmod tools
|
||||
sys-apps/portage python2
|
||||
sys-devel/gcc cxx nptl
|
||||
sys-kernel/gentoo-sources symlink
|
||||
sys-libs/ncurses minimal
|
||||
sys-apps/portage python3 ipc
|
||||
|
||||
www-servers/nginx http
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
dev-db/postgresql-server:9.2
|
||||
www-apache/mod_wsgi
|
||||
dev-python/django
|
||||
dev-python/psycopg
|
||||
dev-db/postgresql-server:9.3
|
||||
www-servers/nginx
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
PYTHONPATH=/var/airport ; export PYTHONPATH
|
||||
DJANGO_SETTINGS_MODULE="etc.settings" ; export DJANGO_SETTINGS_MODULE
|
||||
|
||||
cd /var/airport
|
||||
. bin/activate
|
||||
cd djangoproject
|
||||
uwsgi --socket /var/airport/airport.sock \
|
||||
-w djangoproject.wsgi \
|
||||
--uid airport \
|
||||
--gid airport \
|
||||
--daemonize2 /var/airport/airport.log \
|
||||
-T
|
||||
|
||||
chown airport:nginx /var/airport/airport.sock
|
||||
chmod g+rw /var/airport/airport.sock
|
Loading…
Reference in New Issue