teamplayer: Replaced apache with lighttpd (mercurial repo not working yet)

This commit is contained in:
Albert Hopkins 2010-08-22 09:22:10 -04:00
parent 71c7629cb3
commit 192f0626c8
12 changed files with 101 additions and 122 deletions

View File

@ -1,17 +0,0 @@
Servername HOSTNAME
Listen 80
ProxyPass /repo/ http://localhost:8000/repo/
<VirtualHost *>
DocumentRoot TP_HOME/web/
WSGIDaemonProcess TP_USER user=TP_USER group=TP_USER processes=1 threads=5
WSGIScriptAlias / /etc/teamplayer/teamplayer.wsgi
<Location "/">
WSGIProcessGroup TP_USER
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Location>
</VirtualHost>

View File

@ -1,73 +0,0 @@
# /etc/conf.d/apache2: config file for /etc/init.d/apache2
# When you install a module it is easy to activate or deactivate the modules
# and other features of apache using the APACHE2_OPTS line. Every module should
# install a configuration in /etc/apache2/modules.d. In that file will have an
# <IfDefine NNN> directive where NNN is the option to enable that module.
#
# Here are the options available in the default configuration:
#
# AUTH_DIGEST Enables mod_auth_digest
# AUTHNZ_LDAP Enables authentication through mod_ldap (available if USE=ldap)
# CACHE Enables mod_cache
# DAV Enables mod_dav
# ERRORDOCS Enables default error documents for many languages.
# INFO Enables mod_info, a useful module for debugging
# LANGUAGE Enables content-negotiation based on language and charset.
# LDAP Enables mod_ldap (available if USE=ldap)
# MANUAL Enables /manual/ to be the apache manual (available if USE=docs)
# MEM_CACHE Enables default configuration mod_mem_cache
# PROXY Enables mod_proxy
# SSL Enables SSL (available if USE=ssl)
# SUEXEC Enables running CGI scripts (in USERDIR) through suexec.
# USERDIR Enables /~username mapping to /home/username/public_html
#
#
# The following two options provide the default virtual host for the HTTP and
# HTTPS protocol. YOU NEED TO ENABLE AT LEAST ONE OF THEM, otherwise apache
# will not listen for incomming connections on the approriate port.
#
# DEFAULT_VHOST Enables name-based virtual hosts, with the default
# virtual host being in /var/www/localhost/htdocs
# SSL_DEFAULT_VHOST Enables default vhost for SSL (you should enable this
# when you enable SSL)
#
APACHE2_OPTS="-D INFO -D WSGI -D PROXY"
# Extended options for advanced uses of Apache ONLY
# You don't need to edit these unless you are doing crazy Apache stuff
# As not having them set correctly, or feeding in an incorrect configuration
# via them will result in Apache failing to start
# YOU HAVE BEEN WARNED.
# PID file
#PIDFILE=/var/run/apache2.pid
# timeout for startup/shutdown checks
#TIMEOUT=10
# ServerRoot setting
#SERVERROOT=/usr/lib64/apache2
# Configuration file location
# - If this does NOT start with a '/', then it is treated relative to
# $SERVERROOT by Apache
#CONFIGFILE=/etc/apache2/httpd.conf
# Location to log startup errors to
# They are normally dumped to your terminal.
#STARTUPERRORLOG="/var/log/apache2/startuperror.log"
# A command that outputs a formatted text version of the HTML at the URL
# of the command line. Designed for lynx, however other programs may work.
#LYNX="lynx -dump"
# The URL to your server's mod_status status page.
# Required for status and fullstatus
#STATUSURL="http://localhost/server-status"
# Method to use when reloading the server
# Valid options are 'restart' and 'graceful'
# See http://httpd.apache.org/docs/2.2/stopping.html for information on
# what they do and how they differ.
#RELOAD_TYPE="graceful"

View File

@ -1,4 +1,3 @@

------------------------------------------------------------------------------ ------------------------------------------------------------------------------
TEAMPLAYER CONSOLE TEAMPLAYER CONSOLE
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

80
teamplayer/lighttpd.conf Normal file
View File

@ -0,0 +1,80 @@
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 = 21000
fastcgi.server = (
"/teamplayer.fcgi" => (
"main" => (
"socket" => "TP_DB/teamplayer.sock",
"check-local" => "disable",
)
),
)
alias.url = (
"/m" => "TP_HOME/web/media/",
)
url.rewrite-once = (
"^(/m.*)$" => "$1",
"^(/.*)$" => "/teamplayer.fcgi$1",
)

View File

@ -1,3 +1,4 @@
www-servers/lighttpd fastcgi pcre
app-editors/nano ncurses app-editors/nano ncurses
dev-lang/python sqlite ssl threads xml dev-lang/python sqlite ssl threads xml
sys-kernel/gentoo-sources symlink sys-kernel/gentoo-sources symlink
@ -5,5 +6,3 @@ media-sound/mpd audiofile ffmpeg flac id3 lame network ogg vorbis mad sqlite
media-video/ffmpeg mmx mxext mp3 network x264 media-video/ffmpeg mmx mxext mp3 network x264
media-libs/flac ogg media-libs/flac ogg
dev-python/django postgres dev-python/django postgres
dev-db/sqlite threadsafe
www-servers/apache threads

View File

@ -24,13 +24,12 @@ chroot ${CHROOT} rc-update add postgresql-${PGVER} default
chroot ${CHROOT} getent passwd ${TP_USER} || \ chroot ${CHROOT} getent passwd ${TP_USER} || \
chroot ${CHROOT} useradd -c "Teamplayer Server" -G postgres -U \ chroot ${CHROOT} useradd -c "Teamplayer Server" -G postgres -U \
-d ${TP_HOME} ${TP_USER} -d ${TP_HOME} ${TP_USER}
rm -rf ${TP_HOME} rm -rf ${CHROOT}/${TP_HOME}
hg clone --pull ${HG_REPO} ${CHROOT}/${TP_HOME} hg clone --pull ${HG_REPO} ${CHROOT}/${TP_HOME}
cp ${APPLIANCE}/bash_profile ${CHROOT}${TP_HOME}/.bash_profile cp ${APPLIANCE}/bash_profile ${CHROOT}${TP_HOME}/.bash_profile
chroot ${CHROOT} mkdir -p /etc/teamplayer chroot ${CHROOT} mkdir -p /etc/teamplayer
${M4C} ${APPLIANCE}/teamplayer.wsgi > ${CHROOT}/etc/teamplayer/teamplayer.wsgi
${M4C} ${APPLIANCE}/settings_local.py > ${CHROOT}/etc/teamplayer/settings_local.py ${M4C} ${APPLIANCE}/settings_local.py > ${CHROOT}/etc/teamplayer/settings_local.py
mkdir -p ${CHROOT}${TP_HOME}/bin mkdir -p ${CHROOT}${TP_HOME}/bin
@ -44,11 +43,13 @@ chroot ${CHROOT} rm -rf ${TP_HOME}/web/media/songs
chroot ${CHROOT} ln -s ${TP_DB}/songs ${TP_HOME}/web/media/songs chroot ${CHROOT} ln -s ${TP_DB}/songs ${TP_HOME}/web/media/songs
chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB}/mpd chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB}/mpd
chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} /var/log/teamplayer chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} /var/log/teamplayer
${M4C} ${APPLIANCE}/10_teamplayer.conf > ${CHROOT}/etc/apache2/vhosts.d/10_teamplayer.conf
cp ${APPLIANCE}/apache2.conf ${CHROOT}/etc/conf.d/apache2
${M4C} ${APPLIANCE}/local.start > ${CHROOT}/etc/conf.d/local.start ${M4C} ${APPLIANCE}/local.start > ${CHROOT}/etc/conf.d/local.start
${M4C} ${APPLIANCE}/local.stop > ${CHROOT}/etc/conf.d/local.stop ${M4C} ${APPLIANCE}/local.stop > ${CHROOT}/etc/conf.d/local.stop
cp ${APPLIANCE}/issue ${CHROOT}/etc/issue cp ${APPLIANCE}/issue ${CHROOT}/etc/issue
chroot ${CHROOT} rc-update add apache2 default # lighttpd config
${M4C} ${APPLIANCE}/lighttpd.conf > ${CHROOT}/etc/lighttpd/lighttpd.conf
chroot ${CHROOT} gpasswd -a lighttpd teamplayer
chroot ${CHROOT} rc-update add lighttpd default
chroot ${CHROOT} rc-update add ntpd default chroot ${CHROOT} rc-update add ntpd default

View File

@ -2,12 +2,3 @@
CHROOT="$1" CHROOT="$1"
APPLIANCE="`dirname $0`" APPLIANCE="`dirname $0`"
# set up apache modules in make.conf
cat >> ${CHROOT}/etc/make.conf << EOF
# Apache config for TeamPlayer
APACHE2_MPMS="worker"
APACHE2_MODULES="authz_host dir mime proxy proxy_http"
EOF

View File

@ -1,5 +1,9 @@
TIME_ZONE = 'UTC'
DJANGO_STATIC_MEDIA = False
FORCE_SCRIPT_NAME = ''
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
'TP_HOME/web/templates', 'TP_HOME/web/teamplayer/templates',
) )
TP_STREAM_URL = '/stream.mp3' TP_STREAM_URL = '/stream.mp3'

View File

@ -13,6 +13,11 @@ if [ ! -f "/etc/firstboot" ] ; then
python manage.py syncdb python manage.py syncdb
fi fi
# start the fastcgi daemon
python manage.py runfcgi daemonize=true protocol=fcgi maxrequest=20 \
pidfile="TP_DB/fcgi.pid" socket=TP_DB/teamplayer.sock umask=002 \
> "/var/log/teamplayer/teamplayer.log" 2>&1
# spin! # spin!
python manage.py spin --verbosity=2 $@ > "/var/log/teamplayer/teamplayer.log" 2>&1 & python manage.py spin --verbosity=2 $@ > "/var/log/teamplayer/teamplayer.log" 2>&1 &
echo $! > "TP_DB/tps.pid" echo $! > "TP_DB/tps.pid"

View File

@ -6,5 +6,6 @@ PYTHONPATH="/etc/teamplayer:$PYTHONPATH"
export PYTHONPATH export PYTHONPATH
[ -f "$HOME/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")
python manage.py stop_stream >> "/var/log/teamplayer/teamplayer.log" python manage.py stop_stream >> "/var/log/teamplayer/teamplayer.log"

View File

@ -1,11 +0,0 @@
import os
import sys
path = os.path.dirname(`__file__')
sys.path.append(path)
sys.path.append('TP_HOME/web')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

View File

@ -1,5 +1,6 @@
=dev-db/postgresql-server-8.4* =dev-db/postgresql-server-8.4*
dev-python/django dev-python/django
dev-python/flup
dev-python/python-mpd dev-python/python-mpd
dev-vcs/mercurial dev-vcs/mercurial
media-libs/mutagen media-libs/mutagen
@ -7,5 +8,4 @@ media-sound/mpc
media-sound/mpd media-sound/mpd
net-misc/dhcpcd net-misc/dhcpcd
net-misc/ntp net-misc/ntp
www-apache/mod_wsgi www-servers/lighttpd
www-servers/apache