Skip to content

Commit dead10c

Browse files
committed
trace cherrypy server pid
1 parent cc67f0f commit dead10c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

source/zimonGrafanaIntf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,11 @@ def main(argv):
664664
try:
665665
cherrypy.engine.start()
666666
logger.info("server started")
667-
logger.debug("Server started PID: {}".format(os.getpid()))
667+
with open("/proc/{}/stat".format(os.getpid())) as f:
668+
data = f.read()
669+
foreground_pid_of_group = data.rsplit(" ", 45)[1]
670+
is_in_foreground = str(os.getpid()) == foreground_pid_of_group
671+
logger.debug("Server PID: {}. Process started in the foreground: {}".format(os.getpid(), is_in_foreground))
668672
cherrypy.engine.block()
669673
except TypeError as e:
670674
logger.error("Server request could not be proceed. Reason: {}".format(e))

0 commit comments

Comments
 (0)