teamplayer: Update to work with 2.1
* Switch to python3. * Switch from lighttpd/flup to nginx/uwsgi.
This commit is contained in:
parent
977fcd0d9c
commit
4d7fb4c5d8
|
@ -7,19 +7,16 @@ PGVER = 9.3
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
AVAHI := NO
|
AVAHI := NO
|
||||||
|
|
||||||
M4_DEFS += -D TP_USER=$(TP_USER) -D TP_HOME=$(TP_HOME) -D TP_DB=$(TP_DB) -D TP_HOSTNAME=$(HOSTNAME)
|
M4_DEFS += -D TP_USER=$(TP_USER) -D TP_HOME=$(TP_HOME) -D TP_DB=$(TP_DB) -D HOSTNAME=$(HOSTNAME)
|
||||||
M4C = $(M4) $(M4_DEFS)
|
M4C = $(M4) $(M4_DEFS)
|
||||||
|
|
||||||
inroot := chroot $(CHROOT)
|
inroot := chroot $(CHROOT)
|
||||||
rcdefault := /etc/runlevels/default
|
rcdefault := /etc/runlevels/default
|
||||||
|
|
||||||
post_files = bash_profile settings_local.py start-teamplayer stop-teamplayer
|
post_files = bash_profile settings_local.py start-teamplayer stop-teamplayer
|
||||||
post_files += local.start local.stop issue lighttpd.conf teamplayer.service
|
post_files += local.start local.stop issue nginx.conf teamplayer.service
|
||||||
|
|
||||||
preinstall:
|
preinstall:
|
||||||
$(inroot) $(EMERGE) --select -n $(USEPKG) dev-lang/python:2.7
|
|
||||||
$(inroot) eselect python set python2.7
|
|
||||||
$(inroot) python-updater
|
|
||||||
|
|
||||||
postinstall: $(post_files) $(SCROBBLER_AUTH) urls.py
|
postinstall: $(post_files) $(SCROBBLER_AUTH) urls.py
|
||||||
$(inroot) $(EMERGE) -n $(USEPKG) dev-db/postgresql-server:$(PGVER)
|
$(inroot) $(EMERGE) -n $(USEPKG) dev-db/postgresql-server:$(PGVER)
|
||||||
|
@ -44,7 +41,7 @@ endif
|
||||||
cp bash_profile $(CHROOT)$(TP_HOME)/.bash_profile
|
cp bash_profile $(CHROOT)$(TP_HOME)/.bash_profile
|
||||||
$(inroot) virtualenv $(TP_HOME)
|
$(inroot) virtualenv $(TP_HOME)
|
||||||
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; pip install -e $(TP_HOME)/teamplayer"
|
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; pip install -e $(TP_HOME)/teamplayer"
|
||||||
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; pip install psycopg2 flup Whoosh setproctitle"
|
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; pip install psycopg2 uwsgi Whoosh setproctitle"
|
||||||
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; django-admin.py startproject project $(TP_HOME)"
|
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; django-admin.py startproject project $(TP_HOME)"
|
||||||
chmod +x $(CHROOT)/$(TP_HOME)/manage.py
|
chmod +x $(CHROOT)/$(TP_HOME)/manage.py
|
||||||
$(inroot) ln -sf ../manage.py $(TP_HOME)/bin/manage
|
$(inroot) ln -sf ../manage.py $(TP_HOME)/bin/manage
|
||||||
|
@ -69,10 +66,10 @@ endif
|
||||||
$(inroot) chmod +x /etc/local.d/teamplayer.start
|
$(inroot) chmod +x /etc/local.d/teamplayer.start
|
||||||
$(inroot) chmod +x /etc/local.d/teamplayer.stop
|
$(inroot) chmod +x /etc/local.d/teamplayer.stop
|
||||||
cp issue $(CHROOT)/etc/issue
|
cp issue $(CHROOT)/etc/issue
|
||||||
$(M4C) lighttpd.conf > $(CHROOT)/etc/lighttpd/lighttpd.conf
|
$(M4C) nginx.conf > $(CHROOT)/etc/nginx/nginx.conf
|
||||||
$(inroot) gpasswd -a lighttpd teamplayer
|
$(inroot) gpasswd -a nginx teamplayer
|
||||||
|
|
||||||
$(inroot) ln -sf /etc/init.d/lighttpd $(rcdefault)/lighttpd
|
$(inroot) ln -sf /etc/init.d/nginx $(rcdefault)/nginx
|
||||||
$(inroot) ln -sf /etc/init.d/ntpd $(rcdefault)/ntpd
|
$(inroot) ln -sf /etc/init.d/ntpd $(rcdefault)/ntpd
|
||||||
$(inroot) $(EMERGE) --depclean --with-bdeps=n
|
$(inroot) $(EMERGE) --depclean --with-bdeps=n
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
export DJANGO_SETTINGS_MODULE='project.settings_local'
|
export DJANGO_SETTINGS_MODULE='project.settings_local'
|
||||||
|
export PYTHONPATH="$HOME"
|
||||||
PATH="$HOME/bin:$PATH"
|
PATH="$HOME/bin:$PATH"
|
||||||
|
export LANG="en_US.UTF-8"
|
||||||
. activate
|
. activate
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
var.basedir = "/var/www/localhost"
|
|
||||||
var.logdir = "/var/log/lighttpd"
|
|
||||||
var.statedir = "/var/lib/lighttpd"
|
|
||||||
|
|
||||||
server.modules = (
|
|
||||||
"mod_rewrite",
|
|
||||||
# "mod_redirect",
|
|
||||||
"mod_alias",
|
|
||||||
"mod_access",
|
|
||||||
"mod_fastcgi",
|
|
||||||
# "mod_cml",
|
|
||||||
# "mod_trigger_b4_dl",
|
|
||||||
# "mod_auth",
|
|
||||||
# "mod_status",
|
|
||||||
# "mod_setenv",
|
|
||||||
# "mod_proxy",
|
|
||||||
# "mod_simple_vhost",
|
|
||||||
# "mod_evhost",
|
|
||||||
# "mod_userdir",
|
|
||||||
# "mod_compress",
|
|
||||||
# "mod_ssi",
|
|
||||||
# "mod_usertrack",
|
|
||||||
# "mod_expire",
|
|
||||||
# "mod_secdownload",
|
|
||||||
# "mod_rrdtool",
|
|
||||||
# "mod_webdav",
|
|
||||||
"mod_accesslog"
|
|
||||||
)
|
|
||||||
|
|
||||||
include "mime-types.conf"
|
|
||||||
|
|
||||||
# {{{ server settings
|
|
||||||
server.username = "lighttpd"
|
|
||||||
server.groupname = "lighttpd"
|
|
||||||
|
|
||||||
server.document-root = var.basedir + "/htdocs"
|
|
||||||
server.pid-file = "/var/run/lighttpd.pid"
|
|
||||||
|
|
||||||
server.errorlog = var.logdir + "/error.log"
|
|
||||||
# log errors to syslog instead
|
|
||||||
# server.errorlog-use-syslog = "enable"
|
|
||||||
|
|
||||||
server.indexfiles = ("index.php", "index.html",
|
|
||||||
"index.htm", "default.htm")
|
|
||||||
|
|
||||||
# server.tag = "lighttpd"
|
|
||||||
|
|
||||||
server.follow-symlink = "enable"
|
|
||||||
|
|
||||||
|
|
||||||
# {{{ mod_accesslog
|
|
||||||
accesslog.filename = var.logdir + "/access.log"
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
# {{{ mod_dirlisting
|
|
||||||
# enable directory listings
|
|
||||||
dir-listing.activate = "disable"
|
|
||||||
#
|
|
||||||
|
|
||||||
url.access-deny = ("~", ".inc")
|
|
||||||
|
|
||||||
|
|
||||||
# begin TeamPlayer config
|
|
||||||
server.max-request-size = 100000
|
|
||||||
fastcgi.server = (
|
|
||||||
"/teamplayer.fcgi" => (
|
|
||||||
"main" => (
|
|
||||||
"socket" => "TP_DB/teamplayer.sock",
|
|
||||||
"check-local" => "disable",
|
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
|
||||||
alias.url = (
|
|
||||||
"/static" => "TP_HOME/static/",
|
|
||||||
)
|
|
||||||
|
|
||||||
url.rewrite-once = (
|
|
||||||
"^(/static.*)$" => "$1",
|
|
||||||
"^(/.*)$" => "/teamplayer.fcgi$1",
|
|
||||||
)
|
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
# Settings for TeamPlayer
|
# Settings for TeamPlayer
|
||||||
PYTHON_TARGETS="python2_7 python3_3"
|
NGINX_MODULES_HTTP="auth_basic gzip proxy referer rewrite headers_more uwsgi"
|
||||||
PYTHON_SINGLE_TARGET="python2_7"
|
|
||||||
USE_PYTHON="2.7"
|
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
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;
|
||||||
|
client_max_body_size 100000k;
|
||||||
|
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 TP_HOME/teamplayer/teamplayer/static/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
uwsgi_pass unix://TP_DB/teamplayer.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,5 +1,4 @@
|
||||||
dev-db/postgresql-base
|
dev-db/postgresql-base
|
||||||
dev-db/postgresql-server
|
dev-db/postgresql-server
|
||||||
dev-lang/python:2.7
|
|
||||||
sys-kernel/gentoo-sources
|
sys-kernel/gentoo-sources
|
||||||
virtual/python-imaging
|
virtual/python-imaging
|
||||||
|
|
|
@ -2,8 +2,8 @@ app-editors/nano ncurses
|
||||||
dev-db/sqlite extensions
|
dev-db/sqlite extensions
|
||||||
dev-lang/python sqlite ssl threads xml
|
dev-lang/python sqlite ssl threads xml
|
||||||
media-libs/flac ogg
|
media-libs/flac ogg
|
||||||
media-sound/mpd aac audiofile ffmpeg flac inotify id3tag lame network ogg vorbis mad sqlite
|
media-sound/mpd faad audiofile ffmpeg flac inotify id3tag lame network ogg vorbis mad soup sqlite unicode
|
||||||
media-video/ffmpeg mmx mxext mp3 network x264
|
media-video/ffmpeg avx cpudetection mmx mmxext mp3 network ssse3 x264
|
||||||
sys-apps/kmod openrc tools
|
sys-apps/kmod openrc tools
|
||||||
sys-apps/openrc netifrc
|
sys-apps/openrc netifrc
|
||||||
sys-apps/portage python3 ipc
|
sys-apps/portage python3 ipc
|
||||||
|
@ -12,5 +12,4 @@ sys-fs/udev openrc
|
||||||
sys-kernel/gentoo-sources symlink
|
sys-kernel/gentoo-sources symlink
|
||||||
sys-libs/ncurses minimal
|
sys-libs/ncurses minimal
|
||||||
virtual/ffmpeg x264 mp3
|
virtual/ffmpeg x264 mp3
|
||||||
virtual/python-imaging python_targets_python2_7
|
www-servers/nginx http
|
||||||
www-servers/lighttpd fastcgi pcre
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from settings import *
|
from .settings import *
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# Local Settings
|
# Local Settings
|
||||||
|
@ -127,7 +127,6 @@ TEAMPLAYER = {
|
||||||
'SHAKE_THINGS_UP': 25,
|
'SHAKE_THINGS_UP': 25,
|
||||||
'ALWAYS_SHAKE_THINGS_UP': True,
|
'ALWAYS_SHAKE_THINGS_UP': True,
|
||||||
'HTTP_PORT': 8000,
|
'HTTP_PORT': 8000,
|
||||||
'IPC_PORT': 8080,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
|
@ -136,7 +135,8 @@ DATABASES = {
|
||||||
'NAME': 'teamplayer',
|
'NAME': 'teamplayer',
|
||||||
'HOST': '',
|
'HOST': '',
|
||||||
'PASSWORD': '',
|
'PASSWORD': '',
|
||||||
'PORT': ''
|
'PORT': '',
|
||||||
|
'CONN_MAX_AGE': 300,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
# this should be run as the TP_USER user
|
# this should be run as the TP_USER user
|
||||||
|
|
||||||
PYTHON=python
|
PYTHON=python
|
||||||
|
PYTHONPATH="$HOME" ; export PYTHONPATH
|
||||||
DJANGO_SETTINGS_MODULE="project.settings_local" ; export DJANGO_SETTINGS_MODULE
|
DJANGO_SETTINGS_MODULE="project.settings_local" ; export DJANGO_SETTINGS_MODULE
|
||||||
|
|
||||||
cd ~
|
cd ~
|
||||||
|
@ -12,11 +13,16 @@ if [ ! -f "/etc/firstboot" ] ; then
|
||||||
$PYTHON manage.py collectstatic --noinput --verbosity=0
|
$PYTHON manage.py collectstatic --noinput --verbosity=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# start the fastcgi daemon
|
# start the uwsgi daemon
|
||||||
$PYTHON manage.py runfcgi daemonize=true protocol=fcgi maxrequest=20 \
|
uwsgi --socket TP_DB/teamplayer.sock \
|
||||||
pidfile="TP_DB/fcgi.pid" socket=TP_DB/teamplayer.sock umask=002 \
|
--chmod=660 \
|
||||||
> "/var/log/teamplayer/teamplayer.log" 2>&1
|
-w project.wsgi \
|
||||||
|
--uid teamplayer \
|
||||||
|
--gid teamplayer \
|
||||||
|
--pidfile TP_DB/uwsgi.pid \
|
||||||
|
--daemonize2 /var/log/teamplayer/teamplayer.log \
|
||||||
|
-T
|
||||||
|
|
||||||
# Start the Spin Doctor
|
# Start the Spin Doctor
|
||||||
$PYTHON manage.py spindoctor --verbosity=2 $@ > "/var/log/teamplayer/teamplayer.log" 2>&1 &
|
$PYTHON manage.py spindoctor --verbosity=2 $@ >> "/var/log/teamplayer/teamplayer.log" 2>&1 &
|
||||||
echo $! > "TP_DB/tps.pid"
|
echo $! > "TP_DB/tps.pid"
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
# this should be run as the TP_USER user
|
# this should be run as the TP_USER user
|
||||||
|
|
||||||
PYTHON=python
|
PYTHON=python
|
||||||
|
PYTHONPATH="$HOME" ; export PYTHONPATH
|
||||||
DJANGO_SETTINGS_MODULE="project.settings_local" ; export DJANGO_SETTINGS_MODULE
|
DJANGO_SETTINGS_MODULE="project.settings_local" ; export DJANGO_SETTINGS_MODULE
|
||||||
|
|
||||||
. ~/bin/activate
|
. ~/bin/activate
|
||||||
|
|
||||||
cd ~
|
cd ~
|
||||||
|
|
||||||
#[ -f "TP_DB/tps.pid" ] && kill $(cat "TP_DB/tps.pid")
|
[ -f "TP_DB/tps.pid" ] && kill $(cat "TP_DB/tps.pid")
|
||||||
[ -f "TP_DB/fcgi.pid" ] && kill $(cat "TP_DB/fcgi.pid")
|
[ -f "TP_DB/uwsgi.pid" ] && kill $(cat "TP_DB/uwsgi.pid")
|
||||||
|
|
||||||
$PYTHON manage.py stop_stream >> "/var/log/teamplayer/teamplayer.log"
|
$PYTHON manage.py stop_stream >> "/var/log/teamplayer/teamplayer.log"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
media-sound/mpd
|
media-sound/mpd
|
||||||
net-misc/ntp
|
net-misc/ntp
|
||||||
www-servers/lighttpd
|
www-servers/nginx
|
||||||
|
|
Loading…
Reference in New Issue