Skip to content

Commit c687fd8

Browse files
committed
Updated avail_cores calculation to handle Apple M1 or ARM processors
1 parent 7f253c3 commit c687fd8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

discourse-setup

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ scale_ram_and_cpu() {
258258
avail_cores=`sysctl hw.ncpu | awk '/hw.ncpu:/ {print $2}'`
259259
else
260260
avail_gb=$(check_linux_memory)
261-
avail_cores=$((`awk '/cpu cores/ {print $4;exit}' /proc/cpuinfo`*`sort /proc/cpuinfo | uniq | grep -c "physical id"`))
261+
threads_per_core=$(lscpu | awk 'BEGIN {FS=":"} /Thread\(s\) per core/ {print $2}')
262+
avail_cores=$((`lscpu | awk '/^CPU\(s\)/ {print $2}'`/${threads_per_core}))
262263
fi
263264
echo "Found ${avail_gb}GB of memory and $avail_cores physical CPU cores"
264265

0 commit comments

Comments
 (0)