Josep Puigdemont | 3598bcc | 2017-03-20 13:34:46 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | exit_error() { |
| 4 | echo "-- SERVER ERROR" |
| 5 | lava-test-case server_up --status fail |
| 6 | } |
| 7 | trap exit_error ERR |
| 8 | |
| 9 | do_configure_system() { |
| 10 | local cores=$1 |
| 11 | local vland_iface=$2 |
| 12 | local server_ip=$3 |
| 13 | local driver=${DPDK_DRIVER:-igb_uio} |
| 14 | local pci_dev |
| 15 | |
| 16 | pci_dev=$(basename "$(readlink -f "/sys/class/net/${vland_iface}/device")") |
| 17 | |
| 18 | if ! which dpdk-devbind &>/dev/null; then |
| 19 | echo "ERROR: dpdk not installed" |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | modprobe uio |
| 24 | insmod "$RTE_SDK/$RTE_TARGET/lib/modules/$(uname -r)/extra/dpdk/${driver}.ko" |
| 25 | |
| 26 | dpdk-devbind -u "$pci_dev" |
| 27 | dpdk-devbind -b "$driver" "$pci_dev" |
| 28 | dpdk-devbind -s |
| 29 | |
| 30 | # when using write_config, we need to have /www mounted |
| 31 | configure_ramdisk |
| 32 | |
| 33 | # shellcheck disable=SC2034 |
| 34 | WRITE_CONFIG_CORE="" |
| 35 | WRITE_CONFIG_EVENTS="use select;" |
| 36 | WRITE_CONFIG_LISTEN="listen $server_ip:80 default_server so_keepalive=off;" |
Milosz Wasilewski | 6015206 | 2020-03-02 18:53:29 +0000 | [diff] [blame] | 37 | cat <<-EOF |
Josep Puigdemont | 3598bcc | 2017-03-20 13:34:46 +0100 | [diff] [blame] | 38 | WRITE_CONFIG_CORE=$WRITE_CONFIG_CORE |
| 39 | WRITE_CONFIG_EVENTS=$WRITE_CONFIG_EVENTS |
| 40 | WRITE_CONFIG_LISTEN=$WRITE_CONFIG_LISTEN |
| 41 | EOF |
| 42 | } |
| 43 | |
| 44 | do_stop_nginx() { |
| 45 | if [ -f "${BASE_DIR}/install/run/nginx.pid" ]; then |
| 46 | stop_nginx.sh 1 |
| 47 | fi |
| 48 | } |
| 49 | |
| 50 | do_start_nginx() { |
| 51 | start_nginx.sh 1 |
| 52 | } |
| 53 | |
| 54 | do_write_nginx_config() { |
| 55 | local cores=$1 |
| 56 | |
| 57 | # when using write_config, we need to have /www mounted |
| 58 | write_config "$cores" "${BASE_DIR}/install/etc/nginx/nginx.conf" |
| 59 | } |
| 60 | |
| 61 | do_pre_test_cb() { |
| 62 | rm -rf /dev/hugepages/* |
| 63 | } |
| 64 | |
| 65 | do_post_test_cb() { |
| 66 | local cores=$1 |
| 67 | local pid |
| 68 | |
| 69 | echo "-- AFFINITY $cores" |
| 70 | for pid in $(pgrep nginx); do |
| 71 | taskset -p "$pid" |
| 72 | done |
| 73 | } |
| 74 | |
| 75 | BASE_DIR=${BASE_DIR:-/build} |
| 76 | |
| 77 | if [ ! -f "${BASE_DIR}/environ" ]; then |
| 78 | echo "ERROR: ${BASE_DIR}/environ file not found!" >&2 |
| 79 | exit 1 |
| 80 | fi |
| 81 | |
| 82 | # shellcheck disable=SC1090 |
| 83 | . "${BASE_DIR}/environ" |
| 84 | |
| 85 | echo "-- odp-dpdk-git NGiNX initialized" >&2 |