python supervisord program dependency

Yueyoum picture Yueyoum · Jul 3, 2013 · Viewed 16.3k times · Source

I have [program:A], [program:B] in my supervisord.conf

B depend A, means:

A should start before B.

How to ensure this by supervisor?

Answer

Martijn Pieters picture Martijn Pieters · Jul 3, 2013

supervisord does not directly support dependencies. Your options instead are:

  • Use priorities. Set priority for A to a low value and it'll be started before B, and shut down after B. The default value for priority is 999.

    If you put the two programs into one group as well, that'd let you start and stop them in tandem, with the priorities regulating their start and stop order.

  • Write an event listener that listens for PROCESS_STATE STARTING-to-RUNNING transition and STOPPING events for A, then instruct supervisord to start and stop B according to those events. Have A autostart, but disable autostarting for B, so that the event handler controls it.