Before using this example, please install the python modules 'requests' and 'paho-mqtt (~=2.1.0)' correctly.
pip install requests paho-mqtt~=2.1.0
Modify your user-defined code in "SA.py", and execute "DAI.py" to run the DA by python DAI.py
If you change the file name of SA.py to i.e., "new_SA.py", you can execute it by python DAI.py new_SA
.
For long-running applications, Agent.py can assistant you to run and monitor DAI.py. Agent.py has three abilities.
- Monitor the execution state of DAI.py. If DAI.py is dead or crash, Agent.py executes DAI.py again.
- Restart DAI.py at a specified time everyday.
- If the server is out of service for a while (longer than 15 seconds), once the server is back, Agent.py will restart DAI.py to make sure the connection is good.
To execute DAI.py by Agent.py, you just run Agent.py by python Agent.py
.