changeset bf276f67b2c4 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=bf276f67b2c4
description:
        Add node to id of status

        This allows to distinct status from multiple machines shared the same 
socket.

        issue10706
        review360101002
diffstat:

 CHANGELOG         |   1 +
 bin/trytond-stat  |  10 +++++++---
 trytond/status.py |   3 ++-
 3 files changed, 10 insertions(+), 4 deletions(-)

diffs (57 lines):

diff -r c0f1b12134d8 -r bf276f67b2c4 CHANGELOG
--- a/CHANGELOG Sun Sep 19 00:30:35 2021 +0200
+++ b/CHANGELOG Thu Sep 23 10:04:07 2021 +0200
@@ -1,3 +1,4 @@
+* Add node to id of status
 * Use ImmutableDict for Transaction context
 * Use UNION for 'Or'-ed domain with subqueries
 * Add remove_forbidden_chars in tools
diff -r c0f1b12134d8 -r bf276f67b2c4 bin/trytond-stat
--- a/bin/trytond-stat  Sun Sep 19 00:30:35 2021 +0200
+++ b/bin/trytond-stat  Thu Sep 23 10:04:07 2021 +0200
@@ -39,9 +39,12 @@
         def expired(process):
             return process['expire'] > now
 
-        def format_status(since, pid, request):
+        def format_status(since, id_, request):
             since = str(dt.timedelta(seconds=int(since)))
-            return f"{pid:>5} {since:>18} {request}"
+            pid, node = id_.split('@', 1)
+            if len(node) > 12:
+                node = node[:5] + '…' + node[:6]
+            return f"{pid:>5} {node:<12} {since:>18} {request}"
         status_pad.clear()
         status = [format_status(*i) for i in sorted(
                 ((msg['since'], p['id'], msg['request'])
@@ -54,8 +57,9 @@
         for i, line in enumerate(status, 1):
             status_pad.addnstr(i, 0, line.ljust(pcol), pcol)
         status_pad.addnstr(
-            0, 0, "{pid:>5} {since:>18} {request} ({n})".format(
+            0, 0, "{pid:>5} {node:^12} {since:>18} {request} ({n})".format(
                 pid="pid",
+                node="node",
                 since="TIME" + ('↑' if reverse else '↓'),
                 request="request",
                 n=len(status),
diff -r c0f1b12134d8 -r bf276f67b2c4 trytond/status.py
--- a/trytond/status.py Sun Sep 19 00:30:35 2021 +0200
+++ b/trytond/status.py Thu Sep 23 10:04:07 2021 +0200
@@ -3,6 +3,7 @@
 import json
 import logging
 import os
+import platform
 import socket
 import threading
 import time
@@ -41,7 +42,7 @@
                 'request': str(process.request),
                 })
     return {
-        'id': os.getpid(),
+        'id': '%s@%s' % (os.getpid(), platform.node()),
         'status': msg,
         'caches': list(Cache.stats()),
         }

Reply via email to