Auto detect the number of CPU's and set worker_processes
igor at sysoev.ru
Mon Sep 17 09:55:52 UTC 2012
On Sep 16, 2012, at 3:55 , justin wrote:
> I am trying to get fancy and have `nginx.conf` auto-detect the number of
> CPU's on the server and then set `worker_processes` to that number. Here is
> what I have:
> worker_processes $(cat /proc/cpuinfo | grep "processor" | sort -u | wc
> Unfortunately, that is throwing an error on nginx start. Is it even possible
> to run shell commands from inside nginx configuration files?
You can configure it via command line:
nginx -g "worker_processes `cat /proc/cpuinfo | grep "processor" | sort -u | wc -l`;"
More information about the nginx