--- /dev/null
+# Copyright (C) 2021 Wind River Systems, Inc.\r
+#\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at\r
+#\r
+# http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+import cotyledon\r
+\r
+from o2ims.service.watcher.worker import PollWorker\r
+from o2ims.service.watcher.base import OcloudWather\r
+from o2ims.service.watcher.base import DmsWatcher\r
+\r
+import logging\r
+logger = logging.getLogger(__name__)\r
+\r
+\r
+class WatcherService(cotyledon.Service):\r
+ def __init__(self, worker_id, args) -> None:\r
+ super().__init__(worker_id)\r
+ self.args = args\r
+ self.worker = PollWorker()\r
+\r
+ def run(self):\r
+ try:\r
+ self.worker.add_watcher(OcloudWather())\r
+ self.worker.add_watcher(DmsWatcher())\r
+ self.worker.start()\r
+ except Exception as ex:\r
+ logger.warning(ex.message)\r
+ finally:\r
+ self.worker.stop()\r
+\r
+\r
+def start_watchers(sm=None):\r
+ watchersm = sm if sm else cotyledon.ServiceManager()\r
+ watchersm.add(WatcherService, workers=1, args=())\r
+ return watchersm\r