-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Jiab77/0.2
0.2
- Loading branch information
Showing
3 changed files
with
40 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Minimal PHP server wrapper script | ||
# | ||
# Increasing local web server performances as possible | ||
# https://stackoverflow.com/questions/39842170/load-balancing-php-built-in-server/47103758#47103758 | ||
# https://www.php.net/manual/en/features.commandline.webserver.php | ||
|
||
# Config | ||
LISTEN_INTERFACE="localhost" | ||
LISTEN_PORT=8000 | ||
LISTEN_INTERFACE=${LISTEN_INTERFACE:-localhost} | ||
LISTEN_PORT=${LISTEN_PORT:-8000} | ||
|
||
# Detect server type to use | ||
PHP_SRV_TYPE=$(php -r "if (version_compare(phpversion(), '7.4', '<')) { echo 'tcpserver'; } else { echo 'embedded'; }") | ||
PHP_SRV_TYPE=$(php -r "if (version_compare(phpversion(), '7.4', '<')) { echo 'singlecore'; } else { echo 'multicore'; }") | ||
|
||
# Run detected server type | ||
if [[ $PHP_SRV_TYPE == 'embedded' ]]; then | ||
PHP_CLI_SERVER_WORKERS=$(nproc) php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} libvirtweb.php | ||
if [[ $PHP_SRV_TYPE == 'multicore' ]]; then | ||
# PHP_CLI_SERVER_WORKERS=$(nproc) php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} libvirtweb.php | ||
PHP_CLI_SERVER_WORKERS=$(nproc) php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} -t . | ||
else | ||
tcpserver -v -1 0 ${LISTEN_PORT} ./proxy-to-php-server.sh ./libvirtweb.php | ||
# php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} libvirtweb.php | ||
php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} -t . | ||
fi |