Pavel S.
Pavel S.

Reputation: 12352

Supervisord - program number as a parameter

I have a set of programs managed by supervisord. There is a program, let's call it myprogram, which I need to run in 15 instances. That's easy with the numprocs parameter.

Is there a way to pass the process number as a command line agrument to the program, so that each instance is aware of its number?

I need to achieve the same thing as if I run in command line:

$ myprogram 1
$ myprogram 2
$ myprogram 3
$ myprogram 4
....

Upvotes: 5

Views: 2920

Answers (2)

Nadir
Nadir

Reputation: 715

you can also use an envionment variable: like this:

environment=num=%(process_num)02d

You can then use a getenv() function to get the process number. I usually prefer this method because I prefere reserving parameters to fonctional matters.

Upvotes: 2

JonathanS
JonathanS

Reputation: 321

Yes, in your 'command' parameter in your config, you can use %(process_num)d, eg

command=myprogram %(process_num)d

Upvotes: 5

Related Questions