From 192f0626c878986366e545c74df5396e2857e7a8 Mon Sep 17 00:00:00 2001 From: Albert Hopkins Date: Sun, 22 Aug 2010 09:22:10 -0400 Subject: [PATCH] teamplayer: Replaced apache with lighttpd (mercurial repo not working yet) --- teamplayer/10_teamplayer.conf | 17 -------- teamplayer/apache2.conf | 73 -------------------------------- teamplayer/issue | 1 - teamplayer/lighttpd.conf | 80 +++++++++++++++++++++++++++++++++++ teamplayer/package.use | 3 +- teamplayer/postinstall | 11 ++--- teamplayer/preinstall | 9 ---- teamplayer/settings_local.py | 6 ++- teamplayer/start-teamplayer | 5 +++ teamplayer/stop-teamplayer | 3 +- teamplayer/teamplayer.wsgi | 11 ----- teamplayer/world | 4 +- 12 files changed, 101 insertions(+), 122 deletions(-) delete mode 100644 teamplayer/10_teamplayer.conf delete mode 100644 teamplayer/apache2.conf create mode 100644 teamplayer/lighttpd.conf delete mode 100644 teamplayer/teamplayer.wsgi diff --git a/teamplayer/10_teamplayer.conf b/teamplayer/10_teamplayer.conf deleted file mode 100644 index 61dbdfb..0000000 --- a/teamplayer/10_teamplayer.conf +++ /dev/null @@ -1,17 +0,0 @@ -Servername HOSTNAME -Listen 80 -ProxyPass /repo/ http://localhost:8000/repo/ - - - DocumentRoot TP_HOME/web/ - WSGIDaemonProcess TP_USER user=TP_USER group=TP_USER processes=1 threads=5 - WSGIScriptAlias / /etc/teamplayer/teamplayer.wsgi - - - WSGIProcessGroup TP_USER - WSGIApplicationGroup %{GLOBAL} - Order deny,allow - Allow from all - - - diff --git a/teamplayer/apache2.conf b/teamplayer/apache2.conf deleted file mode 100644 index acc0e98..0000000 --- a/teamplayer/apache2.conf +++ /dev/null @@ -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 -# 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" diff --git a/teamplayer/issue b/teamplayer/issue index f987123..2bca640 100644 --- a/teamplayer/issue +++ b/teamplayer/issue @@ -1,4 +1,3 @@ - ------------------------------------------------------------------------------ TEAMPLAYER CONSOLE ------------------------------------------------------------------------------ diff --git a/teamplayer/lighttpd.conf b/teamplayer/lighttpd.conf new file mode 100644 index 0000000..7219a5e --- /dev/null +++ b/teamplayer/lighttpd.conf @@ -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", +) diff --git a/teamplayer/package.use b/teamplayer/package.use index 8ebdfa3..cbcad71 100644 --- a/teamplayer/package.use +++ b/teamplayer/package.use @@ -1,3 +1,4 @@ +www-servers/lighttpd fastcgi pcre app-editors/nano ncurses dev-lang/python sqlite ssl threads xml 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-libs/flac ogg dev-python/django postgres -dev-db/sqlite threadsafe -www-servers/apache threads diff --git a/teamplayer/postinstall b/teamplayer/postinstall index 2d46800..f3dac2c 100755 --- a/teamplayer/postinstall +++ b/teamplayer/postinstall @@ -24,13 +24,12 @@ chroot ${CHROOT} rc-update add postgresql-${PGVER} default chroot ${CHROOT} getent passwd ${TP_USER} || \ chroot ${CHROOT} useradd -c "Teamplayer Server" -G postgres -U \ -d ${TP_HOME} ${TP_USER} -rm -rf ${TP_HOME} +rm -rf ${CHROOT}/${TP_HOME} hg clone --pull ${HG_REPO} ${CHROOT}/${TP_HOME} cp ${APPLIANCE}/bash_profile ${CHROOT}${TP_HOME}/.bash_profile 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 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} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB}/mpd 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.stop > ${CHROOT}/etc/conf.d/local.stop 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 diff --git a/teamplayer/preinstall b/teamplayer/preinstall index 6a98290..0f31792 100755 --- a/teamplayer/preinstall +++ b/teamplayer/preinstall @@ -2,12 +2,3 @@ CHROOT="$1" 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 - diff --git a/teamplayer/settings_local.py b/teamplayer/settings_local.py index 74d6027..574a084 100644 --- a/teamplayer/settings_local.py +++ b/teamplayer/settings_local.py @@ -1,5 +1,9 @@ +TIME_ZONE = 'UTC' +DJANGO_STATIC_MEDIA = False +FORCE_SCRIPT_NAME = '' + TEMPLATE_DIRS = ( - 'TP_HOME/web/templates', + 'TP_HOME/web/teamplayer/templates', ) TP_STREAM_URL = '/stream.mp3' diff --git a/teamplayer/start-teamplayer b/teamplayer/start-teamplayer index a07fd72..02eb714 100755 --- a/teamplayer/start-teamplayer +++ b/teamplayer/start-teamplayer @@ -13,6 +13,11 @@ if [ ! -f "/etc/firstboot" ] ; then python manage.py syncdb 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! python manage.py spin --verbosity=2 $@ > "/var/log/teamplayer/teamplayer.log" 2>&1 & echo $! > "TP_DB/tps.pid" diff --git a/teamplayer/stop-teamplayer b/teamplayer/stop-teamplayer index 31c8daa..f4ab755 100755 --- a/teamplayer/stop-teamplayer +++ b/teamplayer/stop-teamplayer @@ -6,5 +6,6 @@ PYTHONPATH="/etc/teamplayer:$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" diff --git a/teamplayer/teamplayer.wsgi b/teamplayer/teamplayer.wsgi deleted file mode 100644 index 4ae50d8..0000000 --- a/teamplayer/teamplayer.wsgi +++ /dev/null @@ -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() - diff --git a/teamplayer/world b/teamplayer/world index 3288607..3f994ba 100644 --- a/teamplayer/world +++ b/teamplayer/world @@ -1,5 +1,6 @@ =dev-db/postgresql-server-8.4* dev-python/django +dev-python/flup dev-python/python-mpd dev-vcs/mercurial media-libs/mutagen @@ -7,5 +8,4 @@ media-sound/mpc media-sound/mpd net-misc/dhcpcd net-misc/ntp -www-apache/mod_wsgi -www-servers/apache +www-servers/lighttpd