From 4f475c7697722e946e39e42f38f3dd03a95d8765 Mon Sep 17 00:00:00 2001 From: "matrix.org" Date: Tue, 12 Aug 2014 15:10:52 +0100 Subject: Reference Matrix Home Server --- demo/README | 22 ++++++++++++++++++++++ demo/clean.sh | 16 ++++++++++++++++ demo/start.sh | 24 ++++++++++++++++++++++++ demo/stop.sh | 14 ++++++++++++++ demo/webserver.py | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 demo/README create mode 100755 demo/clean.sh create mode 100755 demo/start.sh create mode 100755 demo/stop.sh create mode 100644 demo/webserver.py (limited to 'demo') diff --git a/demo/README b/demo/README new file mode 100644 index 0000000000..0b584ceb15 --- /dev/null +++ b/demo/README @@ -0,0 +1,22 @@ +Requires you to have done: + python setup.py develop + + +The demo start.sh will start three synapse servers on ports 8080, 8081 and 8082, with host names localhost:$port. This can be easily changed to `hostname`:$port in start.sh if required. +It will also start a web server on port 8000 pointed at the webclient. + +stop.sh will stop the synapse servers and the webclient. + +clean.sh will delete the databases and log files. + +To start a completely new set of servers, run: + + ./demo/stop.sh; ./demo/clean.sh && ./demo/start.sh + + +Logs and sqlitedb will be stored in demo/808{0,1,2}.{log,db} + + + +Also note that when joining a public room on a differnt HS via "#foo:bar.net", then you are (in the current impl) joining a room with room_id "foo". This means that it won't work if your HS already has a room with that name. + diff --git a/demo/clean.sh b/demo/clean.sh new file mode 100755 index 0000000000..d5649fee83 --- /dev/null +++ b/demo/clean.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +DIR="$( cd "$( dirname "$0" )" && pwd )" + +PID_FILE="$DIR/servers.pid" + +if [ -f $PID_FILE ]; then + echo "servers.pid exists!" + exit 1 +fi + +find "$DIR" -name "*.log" -delete +find "$DIR" -name "*.db" -delete + diff --git a/demo/start.sh b/demo/start.sh new file mode 100755 index 0000000000..4701872926 --- /dev/null +++ b/demo/start.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "$0" )" && pwd )" + +CWD=$(pwd) + +cd "$DIR/.." + +for port in "8080" "8081" "8082"; do + echo "Starting server on port $port... " + + python -m synapse.app.homeserver \ + -p "$port" \ + -H "localhost:$port" \ + -f "$DIR/$port.log" \ + -d "$DIR/$port.db" \ + -vv \ + -D --pid-file "$DIR/$port.pid" +done + +echo "Starting webclient on port 8000..." +python "demo/webserver.py" -p 8000 -P "$DIR/webserver.pid" "webclient" + +cd "$CWD" diff --git a/demo/stop.sh b/demo/stop.sh new file mode 100755 index 0000000000..85a1d2c161 --- /dev/null +++ b/demo/stop.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "$0" )" && pwd )" + +FILES=$(find "$DIR" -name "*.pid" -type f); + +for pid_file in $FILES; do + pid=$(cat "$pid_file") + if [[ $pid ]]; then + echo "Killing $pid_file with $pid" + kill $pid + fi +done + diff --git a/demo/webserver.py b/demo/webserver.py new file mode 100644 index 0000000000..78f3213540 --- /dev/null +++ b/demo/webserver.py @@ -0,0 +1,39 @@ +import argparse +import BaseHTTPServer +import os +import SimpleHTTPServer + +from daemonize import Daemonize + + +def setup(): + parser = argparse.ArgumentParser() + parser.add_argument("directory") + parser.add_argument("-p", "--port", dest="port", type=int, default=8080) + parser.add_argument('-P', "--pid-file", dest="pid", default="web.pid") + args = parser.parse_args() + + # Get absolute path to directory to serve, as daemonize changes to '/' + os.chdir(args.directory) + dr = os.getcwd() + + httpd = BaseHTTPServer.HTTPServer( + ('', args.port), + SimpleHTTPServer.SimpleHTTPRequestHandler + ) + + def run(): + os.chdir(dr) + httpd.serve_forever() + + daemon = Daemonize( + app="synapse-webclient", + pid=args.pid, + action=run, + auto_close_fds=False, + ) + + daemon.start() + +if __name__ == '__main__': + setup() -- cgit 1.4.1