setup_nginx.sh 991 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. fw_depends mysql postgresql mongodb nginx mono
  3. sed -i 's|/usr/local/nginx/|'"${IROOT}"'/nginx/|g' nginx.conf
  4. rm -rf lib/
  5. mkdir lib
  6. wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -O nuget.exe
  7. mono nuget.exe install src/packages.config -OutputDirectory lib/
  8. # extra cleaning
  9. rm -rf src/bin src/obj
  10. xbuild src/ServiceStackBenchmark.csproj /t:Clean
  11. xbuild src/ServiceStackBenchmark.csproj /t:Build
  12. # one fastcgi instance for each thread
  13. # load balanced by nginx
  14. port_start=9001
  15. port_end=$(($port_start+$CPU_COUNT))
  16. # nginx
  17. conf="upstream mono {\n"
  18. for port in $(seq $port_start $port_end); do
  19. conf+="\tserver 127.0.0.1:${port};\n"
  20. done
  21. conf+="}"
  22. echo -e $conf > $TROOT/nginx.upstream.conf
  23. nginx -c $TROOT/nginx.conf -g "worker_processes ${CPU_COUNT};"
  24. # To debug, use --printlog --verbose --loglevels=All
  25. for port in $(seq $port_start $port_end); do
  26. MONO_OPTIONS=--gc=sgen fastcgi-mono-server4 --applications=/:$TROOT/src --socket=tcp:127.0.0.1:$port &
  27. done