Set default API_WORKERS

Set the API_WORKERS default to control memory usage. Maximum is nproc / 2 and
minimum is 2.

* Also updates https://review.openstack.org/#/c/117517/ to remove the
  conditional test as API_WORKERS should always be set.
* Update https://review.openstack.org/#/c/109058/ for ceilometer to use API_WORKERS

The following reviews can move forward either as-is or with minor tweaks:
* Keystone: https://review.openstack.org/#/c/121384/ - remove the if check
* Swift: https://review.openstack.org/#/c/121456/ - unabandon, the default
  to 1 is fine, or remove it to match the others.
* Trove: https://review.openstack.org/#/c/121438/ - remove the if check

https://etherpad.openstack.org/p/devstack-workers has the details

Change-Id: Id28d72ebf01c88b7df301edf7d1dd7ec23fcd0d6
diff --git a/stackrc b/stackrc
index 53c8579..0af9c4c 100644
--- a/stackrc
+++ b/stackrc
@@ -508,10 +508,11 @@
 # Allow the use of an alternate protocol (such as https) for service endpoints
 SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http}
 
-# Sets the maximum number of workers for various services and can restrict
+# Sets the maximum number of workers for most services to reduce
 # the memory used where there are a large number of CPUs present
 # (the default number of workers for many services is the number of CPUs)
-# API_WORKERS=4
+# Also sets the minimum number of workers to 2.
+API_WORKERS=${API_WORKERS:=$(( ($(nproc)/2)<2 ? 2 : ($(nproc)/2) ))}
 
 # Local variables:
 # mode: shell-script