Browse Source

Optimise web server for number of cpu cores

Bob Mottram 10 years ago
parent
commit
3b16599b6f
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      install-freedombone.sh

+ 8
- 0
install-freedombone.sh View File

@@ -106,6 +106,9 @@ CONFIGURATION_FILE="freedombone.cfg"
106 106
 
107 107
 SSH_PORT=2222
108 108
 
109
+# number of CPU cores
110
+CPU_CORES=1
111
+
109 112
 # The static IP address of the system within the local network
110 113
 LOCAL_NETWORK_STATIC_IP_ADDRESS="192.168.1.60"
111 114
 
@@ -341,6 +344,9 @@ function read_configuration {
341 344
       if grep -q "LOCAL_NETWORK_STATIC_IP_ADDRESS" $CONFIGURATION_FILE; then
342 345
           LOCAL_NETWORK_STATIC_IP_ADDRESS=$(grep "LOCAL_NETWORK_STATIC_IP_ADDRESS" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
343 346
       fi
347
+      if grep -q "CPU_CORES" $CONFIGURATION_FILE; then
348
+          CPU_CORES=$(grep "CPU_CORES" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
349
+      fi
344 350
       if grep -q "WEBSERVER_LOG_LEVEL" $CONFIGURATION_FILE; then
345 351
           WEBSERVER_LOG_LEVEL=$(grep "WEBSERVER_LOG_LEVEL" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
346 352
       fi
@@ -2997,6 +3003,8 @@ function install_web_server {
2997 3003
       exit 51
2998 3004
   fi
2999 3005
 
3006
+  sed -i "s/worker_processes 4;/worker_processes $CPU_CORES;/g" /etc/nginx/nginx.conf
3007
+
3000 3008
   # install a script to easily enable and disable nginx virtual hosts
3001 3009
   if [ ! -d $INSTALL_DIR ]; then
3002 3010
       mkdir $INSTALL_DIR