setup.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. export DART_HOME=$IROOT/dart-sdk
  3. export PUB_CACHE=$IROOT/.pubcache
  4. export NGINX_HOME=$IROOT/nginx
  5. sed -i 's|host: .*|host: '"${DBHOST}"'|g' postgresql.yaml
  6. sed -i 's|host: .*|host: '"${DBHOST}"'|g' mongodb.yaml
  7. $DART_HOME/bin/pub upgrade
  8. #
  9. # start dart servers
  10. #
  11. current=9001
  12. end=$(($current+$MAX_THREADS))
  13. while [ $current -lt $end ]; do
  14. $DART_HOME/bin/dart server.dart -a 127.0.0.1 -p $current -d ${MAX_THREADS} &
  15. let current=current+1
  16. done
  17. #
  18. # create nginx configuration
  19. #
  20. conf+="worker_processes ${MAX_THREADS};\n"
  21. conf+="error_log /dev/null error;\n"
  22. conf+="events {\n"
  23. conf+="\tworker_connections 1024;\n"
  24. conf+="}\n"
  25. conf+="http {\n"
  26. conf+="\taccess_log off;\n"
  27. conf+="\tinclude ${NGINX_HOME}/conf/mime.types;\n"
  28. conf+="\tdefault_type application/octet-stream;\n"
  29. conf+="\tsendfile on;\n"
  30. conf+="\tupstream dart_cluster {\n"
  31. current=9001
  32. end=$(($current+$MAX_THREADS))
  33. while [ $current -lt $end ]; do
  34. conf+="\t\tserver 127.0.0.1:${current};\n"
  35. let current=current+1
  36. done
  37. conf+="\t\tkeepalive ${MAX_THREADS};\n"
  38. conf+="\t}\n"
  39. conf+="\tserver {\n"
  40. conf+="\t\tlisten 8080;\n"
  41. conf+="\t\tlocation / {\n"
  42. conf+="\t\t\tproxy_pass http://dart_cluster;\n"
  43. conf+="\t\t\tproxy_http_version 1.1;\n"
  44. conf+="\t\t\tproxy_set_header Connection \"\";\n"
  45. conf+="\t\t}\n"
  46. conf+="\t}\n"
  47. conf+="}"
  48. #
  49. # write nginx configuration to disk
  50. #
  51. echo -e $conf > nginx.conf
  52. $NGINX_HOME/sbin/nginx -c $(pwd)/nginx.conf &