diff --git a/syncthing_monitor/__main__.py b/syncthing_monitor/__main__.py index 12f5aad..85ba003 100644 --- a/syncthing_monitor/__main__.py +++ b/syncthing_monitor/__main__.py @@ -58,16 +58,21 @@ class SyncthingMonitor: self.my_device_id = self.syncthing.get_my_device_id() print("Found My Device ID: {0}".format(self.my_device_id), flush=True) + print("Disabling global/local discovery/relay...", flush=True) self.syncthing.disable_announce_discovery_and_relay() - self.syncthing.create_shared_folder(SHARED_FOLDER_ID, SHARED_FOLDER_LABEL, self.syncthing_data_path, - [{'id': self.my_device_id}]) self.syncthing.sync_config() print("Registering etcd update callback...", flush=True) self.etcd.register_device_update_handler(self.update_devices) + print("Attempting to add this device to etcd...", flush=True) self.etcd.add_device_to_cluster(self.my_device_id, self.syncthing_node_name, self.syncthing_publish_address) + print("Added this device to cluster with publish address: {0}".format(self.syncthing_publish_address), + flush=True) + self.update_devices(None) + + print("Entering loop...", flush=True) self.loop() @staticmethod @@ -78,12 +83,17 @@ class SyncthingMonitor: # noinspection PyUnusedLocal def update_devices(self, event): + print("*** Updating syncthing based on change to cluster info ***", flush=True) + print("Obtaining updated device list...", flush=True) device_list = self.etcd.get_device_list() + print("Adding new devices to syncthing...", flush=True) self.syncthing.add_devices(device_list) + print("Updating shared folder with new devices...", flush=True) self.syncthing.create_shared_folder(SHARED_FOLDER_ID, SHARED_FOLDER_LABEL, self.syncthing_data_path, device_list) self.syncthing.sync_config() self.syncthing.print_config() + print("*** Update complete ***", flush=True) if __name__ == "__main__":