Skip to content

Commit

Permalink
initial stab at packaging using ship_it
Browse files Browse the repository at this point in the history
  • Loading branch information
EliAndrewC committed Aug 4, 2014
1 parent 688dbc7 commit 29658e9
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 1 deletion.
1 change: 1 addition & 0 deletions fabfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ship_it import fpm
13 changes: 13 additions & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: Sideboard Framework
name: sideboard
version: 0.1.0
before_install: package-support/preinstall.sh
config_files:
/etc/sideboard/sideboard-server.cfg: package-support/sideboard-server.cfg
/etc/init.d/sideboard-server: package-support/sideboard-server
build_dependencies:
- rpm-build
- prelink
- ruby-devel
run_dependencies:
- python
6 changes: 6 additions & 0 deletions package-support/preinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if ! id -u sideboard &>/dev/null; then
adduser sideboard
fi

mkdir -p /var/run/sideboard
chown sideboard.sideboard /var/run/sideboard
110 changes: 110 additions & 0 deletions package-support/sideboard-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

RETVAL=0
prog="sideboard"

DESC=sideboard
VENV=/opt/sideboard
PYTHON=$VENV/bin/python
CHERRYD=$VENV/bin/cherryd
USER=sideboard
PID_FILE=/var/run/sideboard/$DESC.pid
LOCK_FILE=/var/run/sideboard/$DESC.lock

OPTIONS="-d --pidfile=$PID_FILE --import=sideboard.server"

isrunning() {
PID=`cat $PID_FILE 2>/dev/null`
if [ -n "$PID" ]; then
EXISTS=`ps aux | grep $PID | grep -v grep`
if [ -n "$EXISTS" ]; then
RETVAL=0
else
RETVAL=1
fi
else
RETVAL=1
fi
return $RETVAL
}

start() {
if isrunning; then
echo "Starting $prog: $prog is already running [FAIL]"
RETVAL=1
else
echo -n $"Starting $prog: "
sudo -u $USER $CHERRYD $OPTIONS
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
touch $LOCK_FILE
echo '[OK]'
else
echo '[FAIL]'
fi
fi
return $RETVAL
}

stop() {
PID=`cat $PID_FILE 2>/dev/null`
if [ -n "$PID" ]; then
echo -n $"Shutting down $prog: "
kill $PID
sleep 5
if isrunning; then
echo '[FAIL]'
RETVAL=1
else
rm -f $LOCK_FILE
echo '[OK]'
RETVAL=0
fi
else
echo "$prog is not running"
RETVAL=1
fi
return $RETVAL
}

restart() {
stop
start
}

condrestart() {
[-e $LOCK_FILE] && restart || :
}

status() {
PID=`cat $PID_FILE 2>/dev/null`
if [ -n "$PID" ]; then
echo "$prog is running with pid $PID"
RETVAL=0
else
echo "$prog is not running"
RETVAL=1
fi
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
condrestart|try-restart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
RETVAL=1
esac
14 changes: 14 additions & 0 deletions package-support/sideboard-server.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

ldap.url = "ldap://ldap.applied.sec"
ldap.basedn = "ou=Users,dc=applied,dc=sec"

[cherrypy]
server.socket_host = "0.0.0.0"

[loggers]
root = "INFO"

[handlers]
[[syslog]]
class = "logging.handlers.SysLogHandlers"
address = "/dev/log"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
configobj==5.0.5
cherrypy==3.2.5
cherrypy==3.2.2
#python-ldap==2.3.13
ws4py==0.3.2
SQLAlchemy==0.8.5
Expand Down
1 change: 1 addition & 0 deletions sideboard/websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def upgrade(self, **kwargs):
cherrypy.tools.websockets = WebSocketChecker()

websocket_plugin = WebSocketPlugin(cherrypy.engine)
WebSocketPlugin.start.__func__.priority = 66
websocket_plugin.subscribe()

broadcaster = Caller(WebSocketDispatcher.broadcast)
Expand Down

0 comments on commit 29658e9

Please sign in to comment.