Last active
January 30, 2021 15:50
-
-
Save holly/3cb8099b342c8ce01b2805fd9a7627b2 to your computer and use it in GitHub Desktop.
nginx worker_cpu_affinity generator (inspire from https://github.com/cubicdaiya/nwcagen/blob/master/nwcagen.go)
This file contains hidden or 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
#!/bin/bash | |
cpu_num=$(nproc) | |
array=() | |
echo -n "worker_cpu_affinity " | |
if [ $cpu_num = 1 ]; then | |
echo "auto;" | |
exit | |
fi | |
for i in $(seq 1 $cpu_num); do | |
affinity="" | |
for j in $(seq 1 $cpu_num); do | |
if [ $i = $j ]; then | |
affinity+="1" | |
else | |
affinity+="0" | |
fi | |
done | |
array+=($affinity) | |
done | |
echo -n ${array[@]} | |
echo ";" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment