Auto detect the number of CPU's and set worker_processes

justin nginx-forum at nginx.us
Sat Sep 15 23:55:49 UTC 2012


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
-l);

Unfortunately, that is throwing an error on nginx start. Is it even possible
to run shell commands from inside nginx configuration files?

Thanks.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,230757,230757#msg-230757



More information about the nginx mailing list