deploy.py : choix local/distant interactif + agent_name partout
agent2_deploy : MQTT Last Will + publish retain sur agents/status/{name}
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,10 +42,22 @@ def mqtt_publish(topic: str, message: str):
|
||||
|
||||
def start_mqtt():
|
||||
global _mqtt_pub
|
||||
import json as _json
|
||||
_status_topic = "agents/status/{}".format(MQTT_CLIENT)
|
||||
_offline_payload = _json.dumps({"status": "offline", "agent": MQTT_CLIENT})
|
||||
_online_payload = _json.dumps({
|
||||
"status" : "online",
|
||||
"agent" : MQTT_CLIENT,
|
||||
"jid" : XMPP_JID,
|
||||
"mqtt_inbox": cfg["mqtt_inbox"],
|
||||
})
|
||||
|
||||
_mqtt_pub = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2,
|
||||
client_id=MQTT_CLIENT + "_pub")
|
||||
_mqtt_pub.will_set(_status_topic, _offline_payload, retain=True)
|
||||
_mqtt_pub.connect(MQTT_HOST, MQTT_PORT)
|
||||
_mqtt_pub.loop_start()
|
||||
_mqtt_pub.publish(_status_topic, _online_payload, retain=True)
|
||||
register_to_agent1()
|
||||
|
||||
def register_to_agent1():
|
||||
|
||||
Reference in New Issue
Block a user