Browse Source

H2O: Switch back to running multithreaded (#3122)

Anton Kirilov 7 years ago
parent
commit
6d610e5550
1 changed files with 10 additions and 7 deletions
  1. 10 7
      frameworks/C/h2o/setup.sh

+ 10 - 7
frameworks/C/h2o/setup.sh

@@ -6,17 +6,17 @@ H2O_APP_HOME="${IROOT}/h2o_app"
 BUILD_DIR="${H2O_APP_HOME}_build"
 BUILD_DIR="${H2O_APP_HOME}_build"
 H2O_APP_PROFILE_PORT=54321
 H2O_APP_PROFILE_PORT=54321
 H2O_APP_PROFILE_URL="http://127.0.0.1:$H2O_APP_PROFILE_PORT"
 H2O_APP_PROFILE_URL="http://127.0.0.1:$H2O_APP_PROFILE_PORT"
-PHYSICAL_ENVIRONMENT_THREADS="$CPU_COUNT"
+NUM_WORKERS="$CPU_COUNT"
 
 
 # A hacky way to detect whether we are running in the physical hardware or the cloud environment.
 # A hacky way to detect whether we are running in the physical hardware or the cloud environment.
 if [[ "$CPU_COUNT" -gt 16 ]]; then
 if [[ "$CPU_COUNT" -gt 16 ]]; then
-	CLOUD_ENVIRONMENT=false
+	USE_PROCESSES=false
 	# In the physical hardware environment the number of threads used by the application is not
 	# In the physical hardware environment the number of threads used by the application is not
 	# the same as the number of logical CPU cores that the database server has, so we need to
 	# the same as the number of logical CPU cores that the database server has, so we need to
 	# adjust the maximum number of database connections per thread accordingly.
 	# adjust the maximum number of database connections per thread accordingly.
 	DB_CONN=1
 	DB_CONN=1
 else
 else
-	CLOUD_ENVIRONMENT=true
+	USE_PROCESSES=false
 	DB_CONN=16
 	DB_CONN=16
 fi
 fi
 
 
@@ -69,10 +69,13 @@ popd
 rm -rf "$BUILD_DIR"
 rm -rf "$BUILD_DIR"
 echo "Maximum database connections per thread: $DB_CONN"
 echo "Maximum database connections per thread: $DB_CONN"
 
 
-if "$CLOUD_ENVIRONMENT"; then
-	run_h2o_app 0 "${H2O_APP_HOME}/bin" "${H2O_APP_HOME}/share/h2o_app"
-else
-	for ((i = 0; i < PHYSICAL_ENVIRONMENT_THREADS; i++)); do
+if "$USE_PROCESSES"; then
+	echo "Running $NUM_WORKERS h2o_app processes..."
+
+	for ((i = 0; i < NUM_WORKERS; i++)); do
 		run_h2o_app "$i" "${H2O_APP_HOME}/bin" "${H2O_APP_HOME}/share/h2o_app" -t1
 		run_h2o_app "$i" "${H2O_APP_HOME}/bin" "${H2O_APP_HOME}/share/h2o_app" -t1
 	done
 	done
+else
+	echo "Running h2o_app multithreaded..."
+	run_h2o_app 0 "${H2O_APP_HOME}/bin" "${H2O_APP_HOME}/share/h2o_app"
 fi
 fi