We have a custom C ++ daemon application that deploys once. So, we did this in our Upstart script on Ubuntu 12.04, and it works great:
expect fork exec /path/to/the/app
However, now we need to pass an argument to our application, which contains the number of processors on the machine on which it runs:
cat /proc/cpuinfo | grep processor | wc -l
Our first attempt was as follows:
expect fork exec /path/to/the/app -t `cat /proc/cpuinfo | grep processor | wc -l`
While this is the beginning of our application with the correct -t value, Upstart keeps track of the incorrect pid value, I assume that these cats, grep and wc start all startup processes in exec before our application.
I also tried this, and even this did not work, I think, because installing env var starts the process? Upstart is still tracking the wrong pid:
expect fork script NUM_CORES=32 /path/to/the/app -t $NUM_CORES end script
I also tried doing this in the env stanza, but apparently they do not run commands:
env num_cores=`cat /proc/cpuinfo | grep processor | wc -l`
Also tried to do this on pre-launch, but the env vars installed there has no value in exec exec:
pre-start NUM_CORES=32 end script
Any idea how to properly set this NUM_CORES, and still get Upstart to track the correct pid for our application that deploys once.
environment-variables upstart
Zach
source share