Commits

jujorugo committed 02742ae

arregle un problema en el monitor

  • Participants
  • Parent commits b2be88d
  • Branches juanjose

Comments (0)

Files changed (2)

File nxweb/apps/admin/html/js/monitor-controller.js

     sortable: true,
     columns: [
         {
-            field: "worker"
+            field: "worker_id",
+            title: "Worker Id"
+        },
+        {
+            field: "worker_ip",
+            title: "Worker IP"
         },
         {
             field: "assigned_tasks",
         wmanws_host = resp.data.host;
         wmanws_port = resp.data.port;
         wmanws_uri = "ws://"+wmanws_host+":"+wmanws_port;
-
+        websocket = null;
+        interval = null;
         connect();
 
         function connect() {
+            clearInterval(interval);
             websocket = new WebSocket(wmanws_uri);
             websocket.onopen = function(evt) { onOpen(evt) };
             websocket.onclose = function(evt) { onClose(evt) };
         }
 
         function onClose(evt) {
-            connect();
+//             connect();
+            interval = setInterval(function(){connect()},1000);
+            workerDataSource.data([]);
+            task_queue_DataSource.data([]);
+            tasks_done_DataSource.data([]);
         }
 
         function onMessage(evt) {

File nxweb/apps/wmanws/__init__.py

         debug("Closing Monitor Connection")
     else:
         worker_token = message
-        worker_manager.online(worker_token, websocket)
+        worker_manager.online(worker_token, websocket, environ.get('REMOTE_ADDR'))
         debug("initiating worker connection")
         while True:
             message = None
                 task_monitor = ""
             else:
                 task_monitor = task_monitor[0]
-            monitor_data.append({"worker":worker.worker_number,"assigned_tasks":task_monitor})
+            monitor_data.append({"worker_id":repr(worker.worker_number),"worker_ip":worker.ip,"assigned_tasks":task_monitor})
         return monitor_data
 
     def get_task_queue_monitor(self):
         self.queued_workers[worker_token] = worker
         return worker.token
 
-    def online(self, worker_token, websocket):
+    def online(self, worker_token, websocket, ip_addr):
 
         if self.queued_workers.get(worker_token) is None:
             raise NonexistentWorker()
         worker = copy.copy(self.queued_workers[worker_token])
         del self.queued_workers[worker_token]
         worker.websocket = websocket
+        worker.ip = ip_addr
         self.online_workers[worker_token] = worker
 
 
         self.assigned_tasks = []
         self.attributes     = attributes
         self.worker_number = Worker.counter
+        self.ip = ""
         Worker.counter += 1
 
     def assign_task(self,program_key, task_key):