Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug 643063: add supporting files for slavealloc deployment; r=bear

--HG--
rename : slavealloc-allocator.tac => lib/python/slavealloc/contrib/slavealloc-allocator.tac
rename : slavealloc-combined.tac => lib/python/slavealloc/contrib/slavealloc-combined.tac
rename : slavealloc-ui.tac => lib/python/slavealloc/contrib/slavealloc-ui.tac
  • Loading branch information...
commit 1cfc5979570bb3505e4af9c32b791f4d128a44a0 1 parent f166d3d
@djmitche djmitche authored
View
1  .hgignore
@@ -9,3 +9,4 @@ slavealloc\.db
\..*\.swp
twistd\.pid
.*\.egg-info
+dist/
View
3  MANIFEST.in
@@ -0,0 +1,3 @@
+recursive-include lib/python/slavealloc/contrib *
+recursive-include lib/python/slavealloc/www *
+
View
15 lib/python/slavealloc/contrib/slavealloc-allocator.tac
@@ -0,0 +1,15 @@
+from twisted.application import service
+from slavealloc.daemon.application import Allocator
+from twisted.python.logfile import LogFile
+from twisted.python.log import ILogObserver, FileLogObserver
+
+application = service.Application("slavealloc")
+
+# set up logfile rotation
+logfile = LogFile.fromFullPath("slavealloc.log", rotateLength=1024**2,
+ maxRotatedFiles=10)
+application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
+
+allocator = Allocator(http_port='tcp:8010', db_url='sqlite:///slavealloc.db',
+ run_allocator=True)
+allocator.setServiceParent(application)
View
8 slavealloc-combined.tac → ...lavealloc/contrib/slavealloc-combined.tac
@@ -1,7 +1,15 @@
from twisted.application import service
from slavealloc.daemon.application import Allocator
+from twisted.python.logfile import LogFile
+from twisted.python.log import ILogObserver, FileLogObserver
application = service.Application("slavealloc")
+
+# set up logfile rotation
+logfile = LogFile.fromFullPath("slavealloc.log", rotateLength=1024**2,
+ maxRotatedFiles=10)
+application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
+
allocator = Allocator(http_port='tcp:8012', db_url='sqlite:///slavealloc.db',
run_allocator=True,
run_ui=True)
View
22 lib/python/slavealloc/contrib/slavealloc-nginx.conf
@@ -0,0 +1,22 @@
+server {
+ listen 80;
+ server_name slavealloc.build.mozilla.org slavealloc;
+
+ # proxy the API to the Twisted daemon
+ location ~ ^/(api|gettac) {
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_redirect false;
+ proxy_pass http://127.0.0.1:1080;
+ }
+
+ # serve the UI directly
+ location /ui {
+ # note that this path depends on slavealloc being installed with pip
+ alias /tools/slavealloc/src/tools/lib/python/slavealloc/www;
+ }
+
+ # and redirect / to /ui
+ location = / {
+ rewrite ^(.*) /ui permanent;
+ }
+}
View
22 lib/python/slavealloc/contrib/slavealloc-staging-nginx.conf
@@ -0,0 +1,22 @@
+server {
+ listen 80;
+ server_name slavealloc-staging.build.mozilla.org slavealloc-staging;
+
+ # proxy the API to the Twisted daemon
+ location ~ ^/(api|gettac) {
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_redirect false;
+ proxy_pass http://127.0.0.1:1079;
+ }
+
+ # serve the UI directly
+ location /ui {
+ # note that this path depends on slavealloc being installed with pip
+ alias /tools/slavealloc/src/tools/lib/python/slavealloc/www;
+ }
+
+ # and redirect / to /ui
+ location = / {
+ rewrite ^(.*) /ui permanent;
+ }
+}
View
115 lib/python/slavealloc/contrib/slavealloc-staging.initd
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# slavealloc-staging
+#
+# chkconfig: 345 85 15
+# description: slave allocator daemon
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+NAME=staging-1079
+BASEDIR=/builds/slavealloc/$NAME
+lockfile=/var/lock/subsys/slavealloc-$NAME
+pidfile=$BASEDIR/twistd.pid
+LOGFILE=$BASEDIR/slavealloc.log
+TACFILE=$BASEDIR/slavealloc.tac
+USER=slavealloc
+GROUP=slavealloc
+VIRTUALENV=/tools/slavealloc
+
+start() {
+ [ -x $VIRTUALENV/bin/twistd ] || exit 5
+ [ -f $TACFILE ] || exit 6
+ echo -n "starting slavealloc $NAME"
+ cd $BASEDIR # --rundir doesn't work with the customized .tac logging
+ daemon $VIRTUALENV/bin/twistd \
+ --pidfile=$pidfile \
+ --rundir=$BASEDIR \
+ --python=$TACFILE \
+ --logfile=$LOGFILE \
+ --uid=$USER \
+ --gid=$GROUP || echo "FAILED"
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n "stopping slavealloc $NAME"
+ kill `cat "${pidfile}"`
+ echo
+ rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop && start
+}
+
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ if [ -f $pidfile ]; then
+ if kill -0 `cat $pidfile`; then
+ echo "running"
+ return 0
+ else
+ echo "dead but pidfile remains"
+ return 1
+ fi
+ else
+ if [ -f $lockfile ]; then
+ echo "dead but lockfile remains"
+ return 2
+ else
+ echo "not running"
+ return 3
+ fi
+ fi
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
View
15 lib/python/slavealloc/contrib/slavealloc-ui.tac
@@ -0,0 +1,15 @@
+from twisted.application import service
+from slavealloc.daemon.application import Allocator
+from twisted.python.logfile import LogFile
+from twisted.python.log import ILogObserver, FileLogObserver
+
+application = service.Application("slavealloc")
+
+# set up logfile rotation
+logfile = LogFile.fromFullPath("slavealloc.log", rotateLength=1024**2,
+ maxRotatedFiles=10)
+application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
+
+allocator = Allocator(http_port='tcp:8010', db_url='sqlite:///slavealloc.db',
+ run_ui=True)
+allocator.setServiceParent(application)
View
115 lib/python/slavealloc/contrib/slavealloc.initd
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# slavealloc
+#
+# chkconfig: 345 85 15
+# description: slave allocator daemon
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+NAME=production-1080
+BASEDIR=/builds/slavealloc/$NAME
+lockfile=/var/lock/subsys/slavealloc-$NAME
+pidfile=$BASEDIR/twistd.pid
+LOGFILE=$BASEDIR/slavealloc.log
+TACFILE=$BASEDIR/slavealloc.tac
+USER=slavealloc
+GROUP=slavealloc
+VIRTUALENV=/tools/slavealloc
+
+start() {
+ [ -x $VIRTUALENV/bin/twistd ] || exit 5
+ [ -f $TACFILE ] || exit 6
+ echo -n "starting slavealloc $NAME"
+ cd $BASEDIR # --rundir doesn't work with the customized .tac logging
+ daemon $VIRTUALENV/bin/twistd \
+ --pidfile=$pidfile \
+ --rundir=$BASEDIR \
+ --python=$TACFILE \
+ --logfile=$LOGFILE \
+ --uid=$USER \
+ --gid=$GROUP || echo "FAILED"
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n "stopping slavealloc $NAME"
+ kill `cat "${pidfile}"`
+ echo
+ rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop && start
+}
+
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ if [ -f $pidfile ]; then
+ if kill -0 `cat $pidfile`; then
+ echo "running"
+ return 0
+ else
+ echo "dead but pidfile remains"
+ return 1
+ fi
+ else
+ if [ -f $lockfile ]; then
+ echo "dead but lockfile remains"
+ return 2
+ else
+ echo "not running"
+ return 3
+ fi
+ fi
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
View
5 setup.py
@@ -28,5 +28,8 @@
'console_scripts': [
'slavealloc = slavealloc.scripts.main:main'
],
- }
+ },
+
+ # include files listed in MANIFEST.in
+ include_package_data = True,
)
View
7 slavealloc-allocator.tac
@@ -1,7 +0,0 @@
-from twisted.application import service
-from slavealloc.daemon.application import Allocator
-
-application = service.Application("slavealloc")
-allocator = Allocator(http_port='tcp:8010', db_url='sqlite:///slavealloc.db',
- run_allocator=True)
-allocator.setServiceParent(application)
View
7 slavealloc-ui.tac
@@ -1,7 +0,0 @@
-from twisted.application import service
-from slavealloc.daemon.application import Allocator
-
-application = service.Application("slavealloc")
-allocator = Allocator(http_port='tcp:8010', db_url='sqlite:///slavealloc.db',
- run_ui=True)
-allocator.setServiceParent(application)
Please sign in to comment.
Something went wrong with that request. Please try again.