run.sh 608 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. CPU_COUNT=$(nproc)
  3. # one fastcgi instance for each thread
  4. # load balanced by nginx
  5. port_start=9001
  6. port_end=$(($port_start+$CPU_COUNT))
  7. # To debug, use --printlog --verbose --loglevels=All
  8. for port in $(seq $port_start $port_end); do
  9. MONO_OPTIONS=--gc=sgen fastcgi-mono-server4 --applications=/:/nancy/src --socket=tcp:127.0.0.1:$port &
  10. done
  11. sleep 5s
  12. # nginx
  13. conf="upstream mono {\n"
  14. for port in $(seq $port_start $port_end); do
  15. conf+="\tserver 127.0.0.1:${port};\n"
  16. done
  17. conf+="}"
  18. echo -e $conf > nginx.upstream.conf
  19. nginx -c /nancy/nginx.conf -g "worker_processes ${CPU_COUNT};"
  20. wait