REVEN-Axion 2018v1.4.4
monitor_status_servers.py

This shows how to monitor the status of the running servers. See this page for more information.

1 import reven
2 import reven_api
3 import time
4 
5 host = "localhost"
6 launcher = reven_api.launcher_connection(host, 8080)
7 sleep_duration = 4 # in seconds
8 
9 def get_execution_status(host, port):
10  try:
11  project = reven.Project(host, port)
12  return project.execution_status() # we had a license, normally return the ExecutionStatus
13  except reven.reven_api.LicenseError as le:
14  # no license, return the ExecutionStatus from the LicenseError
15  return reven.ExecutionProgress.from_license_error(le)
16 
17 def print_status_servers(launcher):
18  for server in launcher.list_servers():
19  project = server.project
20  port = server.reven_server.port
21  try:
22  status = get_execution_status(host, port)
23  print("{} on {}: {}".format(project, port, status))
24  except RuntimeError as re:
25  print("{} on {}: an error occurred ({})".format(project, port, re))
26 
27 while True:
28  print_status_servers(launcher)
29  print("")
30  time.sleep(sleep_duration)