start.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. DIR="$( cd "$( dirname "$0" )" && pwd )"
  3. CWD=$(pwd)
  4. cd "$DIR/.."
  5. mkdir -p demo/etc
  6. export PYTHONPATH=$(readlink -f $(pwd))
  7. echo $PYTHONPATH
  8. for port in 8080 8081 8082; do
  9. echo "Starting server on port $port... "
  10. https_port=$((port + 400))
  11. mkdir -p demo/$port
  12. pushd demo/$port
  13. #rm $DIR/etc/$port.config
  14. python -m synapse.app.homeserver \
  15. --generate-config \
  16. -H "localhost:$https_port" \
  17. --config-path "$DIR/etc/$port.config" \
  18. --report-stats no
  19. printf '\n\n# Customisation made by demo/start.sh\n' >> $DIR/etc/$port.config
  20. echo 'enable_registration: true' >> $DIR/etc/$port.config
  21. # Check script parameters
  22. if [ $# -eq 1 ]; then
  23. if [ $1 = "--no-rate-limit" ]; then
  24. # messages rate limit
  25. echo 'rc_messages_per_second: 1000' >> $DIR/etc/$port.config
  26. echo 'rc_message_burst_count: 1000' >> $DIR/etc/$port.config
  27. # registration rate limit
  28. printf 'rc_registration:\n per_second: 1000\n burst_count: 1000\n' >> $DIR/etc/$port.config
  29. # login rate limit
  30. echo 'rc_login:' >> $DIR/etc/$port.config
  31. printf ' address:\n per_second: 1000\n burst_count: 1000\n' >> $DIR/etc/$port.config
  32. printf ' account:\n per_second: 1000\n burst_count: 1000\n' >> $DIR/etc/$port.config
  33. printf ' failed_attempts:\n per_second: 1000\n burst_count: 1000\n' >> $DIR/etc/$port.config
  34. fi
  35. fi
  36. if ! grep -F "full_twisted_stacktraces" -q $DIR/etc/$port.config; then
  37. echo "full_twisted_stacktraces: true" >> $DIR/etc/$port.config
  38. fi
  39. if ! grep -F "report_stats" -q $DIR/etc/$port.config ; then
  40. echo "report_stats: false" >> $DIR/etc/$port.config
  41. fi
  42. python -m synapse.app.homeserver \
  43. --config-path "$DIR/etc/$port.config" \
  44. -D \
  45. -vv \
  46. popd
  47. done
  48. cd "$CWD"