Similar to SUPERVISOR_PROCESS_NAME env var, would be useful to have only the process number as a var in the running processes' execution environments.
I've checked http://supervisord.org/subprocess.html#subprocess-environment and there is not such var.
Thx.
If numprocs >1 then the process name must always include the number.
I'm aware of it, but you have to do some extra work to isolate the process number. It would be a nice (an apparently easy and inofensive) addition.
You can set an environment variable with just the process number by using the environment= option in a program or eventlistener section. It supports the %(process_num)d expansion:
[program:cat]
command = /bin/cat
process_name = cat_%(process_num)d
environment = PROCESS_NUM=%(process_num)d
This has been supported since at least 3.0a8 and it is documented in the manual. I added a test for it in 84ac9daf37a2541a58a4f50ab5861a257b5dac3a so it should continue working.
Thanks for the tip. I also appreciate you including the test to ensure it does not breaks in the future. Thank you very much.
As it would be very useful in my workflow and doesn't looks like that will do any harm, is it likely for a PR with that feature to be merged? I'm [still] no Pyhton programmer, just can read code, but it looks like a low-hanging fruit to get my feet wet.
What would be an appropiate variable name? SUPERVISOR_PROCESS_NUM? (as there is SUPERVISOR_PROCESS_NAME)
Also, pointers for where to start at the code will be appreciated.
TIA.
As it would be very useful in my workflow and doesn't looks like that will do any harm,
is it likely for a PR with that feature to be merged?
I think it's pretty reasonable.
What would be an appropiate variable name? SUPERVISOR_PROCESS_NUM?
(as there is SUPERVISOR_PROCESS_NAME)
The %(process_name)s expansion is set in the environment as SUPERVISOR_PROCESS_NAME, so %(process_num)s should probably be SUPERVISOR_PROCESS_NUM for consistency.
Also, pointers for where to start at the code will be appreciated.
Make changes on the master branch. Use python setup.py develop to set up for development and then running supervisord or supervisorctl will run the code from your checkout. It is useful to run supervisord -n -c /path/to/a/supervisord.conf (no daemonize, explicit config) for development. Use tox to run the test suite.
The config file is parsed by options.py. Look for process_num in that file. Parsing the config file section creates a ProcessConfig object. Processes are spawned in process.py using info in the ProcessConfig. Look for SUPERVISOR_PROCESS_NAME in that file to see how environment variables are set from the ProcessConfig.
Just forked to start tinkering (no promise, yet). However, since I've never seen/used Tox before I went the TravisCI way: http://docs.travis-ci.com/user/getting-started/
It all worked like a charm as can be seen at https://travis-ci.org/pataquets/supervisor/builds/42478514
No Tox needed, I wonder. Free CI ;)
tox is pretty simple and free also.
The advantage of tox is that you can run it without committing or pushing your code, unlike Travis CI.
If you want to try it:
pip install tox
tox
Full details at http://tox.testrun.org
Most helpful comment
You can set an environment variable with just the process number by using the
environment=option in a program or eventlistener section. It supports the%(process_num)dexpansion:This has been supported since at least 3.0a8 and it is documented in the manual. I added a test for it in 84ac9daf37a2541a58a4f50ab5861a257b5dac3a so it should continue working.