setup.sh 1.3 KB

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