Process monitoring tool in python

2019-06-02 15:08发布

问题:

I am trying to build a process monitoring tool in python, with some basic task handling

  1. start a process, check running status or stop a process
  2. consider process dependency before starting a process. eg config dependency file

    ` P1->P2,P3

    P2->

    P3->P4,P5

    P4->

    P5->`

    So if we give command to start P1, it should infer from config that it is dependent on P2,P3, start P2, start P3, again infer that P3 is dependent on P4,P5, run P4,P5, then finally run P1 once all dependent process are running.

This seems to be a common utility usage, what is the best way to achieve this using python. Should I be creating a full dependency list for each process in the config? eg. serializing dependency in the form P1->P2,P4,P5,P3 and then run for each P if(!isRunning(P)){run(P)} Any suggestions to solve this problem efficiently wold be very helpful.