Supervisor: Feature request: multiple line support in command configuration

Created on 8 Aug 2012  ·  4Comments  ·  Source: Supervisor/supervisor

It will be nice if I can put multiple lines in the command value in the configuration file, like this:

[program:my-program]
command=my-program \
  --long-option very very very long parameter \
  --another-long-option very very very long parameter

Most helpful comment

Supervisor uses the ConfigParser module to parse supervisord.conf. It supports values that span multiple lines.

It works almost as you have written above. The extra lines must be indented and leave off the \:

[supervisord]

[program:echo_argv]
command=/path/to/echo_argv
    --long-option 'very very very long parameter'
    --another-long-option 'very very very long parameter'

We can test that it works with a demo script that echoes argv:

#!/usr/bin/env python -u
import sys
import pprint
pprint.pprint(sys.argv)

Running supervisord without daemonizing and at the debug level lets us easily see the output:

$ supervisord --loglevel debug -n -c /path/to/supervisord.conf 
2012-09-03 17:33:06,045 INFO Increased RLIMIT_NOFILE limit to 1024
2012-09-03 17:33:06,048 INFO supervisord started with pid 964
2012-09-03 17:33:07,052 INFO spawned: 'echo_argv' with pid 967
2012-09-03 17:33:07,096 DEBG 'echo_argv' stdout output:
['/path/to/echo_argv',
 '--long-option',
 'very very very long parameter',
 '--another-long-option',
 'very very very long parameter']

All 4 comments

I second that motion.

Supervisor uses the ConfigParser module to parse supervisord.conf. It supports values that span multiple lines.

It works almost as you have written above. The extra lines must be indented and leave off the \:

[supervisord]

[program:echo_argv]
command=/path/to/echo_argv
    --long-option 'very very very long parameter'
    --another-long-option 'very very very long parameter'

We can test that it works with a demo script that echoes argv:

#!/usr/bin/env python -u
import sys
import pprint
pprint.pprint(sys.argv)

Running supervisord without daemonizing and at the debug level lets us easily see the output:

$ supervisord --loglevel debug -n -c /path/to/supervisord.conf 
2012-09-03 17:33:06,045 INFO Increased RLIMIT_NOFILE limit to 1024
2012-09-03 17:33:06,048 INFO supervisord started with pid 964
2012-09-03 17:33:07,052 INFO spawned: 'echo_argv' with pid 967
2012-09-03 17:33:07,096 DEBG 'echo_argv' stdout output:
['/path/to/echo_argv',
 '--long-option',
 'very very very long parameter',
 '--another-long-option',
 'very very very long parameter']

Nice. Thanks a lot.

Is it possible to span 'very very very long parameter' multiple lines (still as a single argument)?

Was this page helpful?
0 / 5 - 0 ratings