私はステータスを取得し、このような条件分岐を作るために、Pythonコードからsupervisorctl
を使用してプロセスを操作したいと思います:Pythonコードからプロセスの状態を取得するには?
import subprocess
status = subprocess.run(["sudo", "supervisorctl", "status", "my_process"])
if status == "STOPPED":
# Do something
else:
# Do another thing
しかし、これは動作しません。 subprocess.run
はCompletedProcess(args=['sudo', 'supervisorctl', 'status', 'my_status'], returncode=0)
を返します。レスポンスにはステータスがありません。
ステータスを取得する方法はありますか?
ありがとう!これは機能します。 – Udomomo