Skip to content

Commit df64418

Browse files
committed
Only parse a single line from lscpu to get the Cpu(s) count. Avoid localization.
1 parent 7d548ad commit df64418

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

discourse-setup

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
export LC_ALL=C # lscpu output is localized.
3+
24
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
35
cd $DIR
46

@@ -258,7 +260,7 @@ scale_ram_and_cpu() {
258260
else
259261
avail_gb=$(check_linux_memory)
260262
threads_per_core=$(lscpu | awk 'BEGIN {FS=":"} /Thread\(s\) per core/ {print $2}')
261-
avail_cores=$((`lscpu | awk '/^CPU\(s\)/ {print $2}'`*${threads_per_core}))
263+
avail_cores=$((`lscpu | awk '/^CPU\(s\):[[:blank:]]+[0-9]+[[:blank:]]*$/ {print $2; exit}'`*${threads_per_core}))
262264
fi
263265
echo "Found ${avail_gb}GB of memory and $avail_cores physical CPU cores"
264266

0 commit comments

Comments
 (0)