Skip to content

Commit

Permalink
Replace caddy by nginx web server
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiguash committed Aug 14, 2023
1 parent 0453d22 commit 261b40e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ NCPUS=$(lscpu | grep '^CPU(s):' | awk '{print $2}')
> This setting is optional and not necessarily recommended for configurations
> with small number of CPUs and limited disk performance.
Use `./test/bin/start_webserver.sh` to run a caddy web server to serve the
Use `./test/bin/start_webserver.sh` to run an `nginx` web server to serve the
images needed for the build.

Use `./test/bin/build_images.sh` to build all of the images for all of the
Expand Down Expand Up @@ -371,7 +371,7 @@ $ ./test/bin/manage_hypervisor_config.sh cleanup
#### Creating Test Infrastructure
Use `./test/bin/start_webserver.sh` to run a caddy web server to serve the
Use `./test/bin/start_webserver.sh` to run an `nginx` web server to serve the
images needed for the test scenarios.
Use `./test/bin/scenario.sh` to create test infrastructure for a scenario
Expand Down
2 changes: 1 addition & 1 deletion test/bin/cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ for scenario in scenarios/*.sh; do
./bin/scenario.sh cleanup "${scenario}"
done

pkill caddy || true
sudo pkill nginx || true

rm -rf "${IMAGEDIR}"
39 changes: 31 additions & 8 deletions test/bin/start_webserver.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# This script should be run on the hypervisor to set up a caddy
# file-server for the images used by Vms running test scenarios.
# This script should be run on the hypervisor to set up an nginx
# file-server for the images used by VMs running test scenarios.

set -euo pipefail

Expand All @@ -13,9 +13,32 @@ echo "Starting web server in ${IMAGEDIR}"
mkdir -p "${IMAGEDIR}"
cd "${IMAGEDIR}"

pkill caddy || true
nohup caddy file-server \
--access-log \
--browse \
--listen "0.0.0.0:${WEB_SERVER_PORT}" \
--root "${IMAGEDIR}" >caddy.log 2>&1 &
NGINX_CONFIG="${IMAGEDIR}/nginx.conf"
cat > "${NGINX_CONFIG}" <<EOF
worker_processes 8;
events {
}
http {
access_log /dev/null;
error_log ${IMAGEDIR}/nginx_error.log;
server {
listen 0.0.0.0:${WEB_SERVER_PORT};
root ${IMAGEDIR};
}
}
pid ${IMAGEDIR}/nginx.pid;
daemon on;
EOF

# Allow the current user to write to nginx temporary directories
sudo chgrp -R "$(id -gn)" /var/lib/nginx

# Kill running nginx processes and wait until down
sudo pkill nginx || true
while pidof nginx &>/dev/null ; do
sleep 1
done

nginx \
-c "${NGINX_CONFIG}" \
-e "${IMAGEDIR}/nginx.log"

0 comments on commit 261b40e

Please sign in to comment.