Skip to content
Snippets Groups Projects
Commit 1ec61f8f authored by Hannes Feldt's avatar Hannes Feldt Committed by Jan David Mol
Browse files

L2SS-1710: Central Monitor Lobster Migration

parent 131e0da7
No related branches found
No related tags found
1 merge request!910L2SS-1710: Central Monitor Lobster Migration
...@@ -149,3 +149,6 @@ ij_yaml_spaces_within_brackets = true ...@@ -149,3 +149,6 @@ ij_yaml_spaces_within_brackets = true
[{*.hcl,*.hcl.tmpl,*.nomad,*.hcl.j2}] [{*.hcl,*.hcl.tmpl,*.nomad,*.hcl.j2}]
indent_size = 2 indent_size = 2
[*.proto]
indent_size = 2
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
**/vscode-server.tar **/vscode-server.tar
**/*.orig **/*.orig
**/venv **/venv
**/*_pb2.*
**/*_pb2_grpc.*
tangostationcontrol/build tangostationcontrol/build
tangostationcontrol/cover tangostationcontrol/cover
......
...@@ -391,6 +391,7 @@ deploy_nomad: ...@@ -391,6 +391,7 @@ deploy_nomad:
- jupyter - jupyter
- snmp-exporter - snmp-exporter
- landing-page - landing-page
- rpc-server
environment: environment:
name: $STATION name: $STATION
script: script:
......
...@@ -161,6 +161,7 @@ Next change the version in the following places: ...@@ -161,6 +161,7 @@ Next change the version in the following places:
# Release Notes # Release Notes
* 0.34.0 Add gRPC based 'external' station control service
* 0.33.3 Add support for new PCON devices (ACX) * 0.33.3 Add support for new PCON devices (ACX)
* 0.33.2 Fix for XSTs in Observations: Also write FPGA_xst_nof_crosslets_RW * 0.33.2 Fix for XSTs in Observations: Also write FPGA_xst_nof_crosslets_RW
* 0.33.1 SDPFirmware: replace FPGA_ucp monitoring points with new TR_ucp ones * 0.33.1 SDPFirmware: replace FPGA_ucp monitoring points with new TR_ucp ones
......
job "rpc-server" {
datacenters = ["stat"]
type = "service"
reschedule {
unlimited = true
delay = "30s"
delay_function = "constant"
}
group "station-rpc" {
network {
mode = "bridge"
port "grpc" {
static = "50051"
host_network = "external"
}
}
service {
name = "rpc"
port = "grpc"
}
task "l2ss-rpc-server" {
driver = "docker"
config {
image = "[[ $.registry.astron.url ]]/lofar-device-base:[[ $.image_tag ]]"
entrypoint = [""]
command = "l2ss-rpc-server"
}
env {
TANGO_HOST = "tango.service.consul:10000"
}
resources {
cpu = 25
memory = 512
}
}
}
}
0.33.3 0.34.0
syntax = "proto3";
service Observation {
rpc StartObservation(StartObservationRequest) returns (ObservationReply){}
rpc StopObservation(StopObservationRequest) returns (ObservationReply) {}
}
message StartObservationRequest {
string configuration = 1;
}
message StopObservationRequest {
int64 observation_id = 1;
}
message ObservationReply {
bool success = 1;
string exception = 2;
}
...@@ -23,3 +23,5 @@ prometheus-client # Apache 2 ...@@ -23,3 +23,5 @@ prometheus-client # Apache 2
dnspython # ISC dnspython # ISC
logfmter # MIT logfmter # MIT
psutil >= 5.4.6 # BSD3 psutil >= 5.4.6 # BSD3
grpcio # Apache 2
grpcio-tools # Apache 2
...@@ -35,6 +35,7 @@ console_scripts = ...@@ -35,6 +35,7 @@ console_scripts =
l2ss-analyse-dsconfig-hierarchies = tangostationcontrol.toolkit.analyse_dsconfig_hierarchies:main l2ss-analyse-dsconfig-hierarchies = tangostationcontrol.toolkit.analyse_dsconfig_hierarchies:main
l2ss-version = tangostationcontrol:print_version l2ss-version = tangostationcontrol:print_version
l2ss-health = tangostationcontrol.common.health:main l2ss-health = tangostationcontrol.common.health:main
l2ss-rpc-server = tangostationcontrol.rpc.server:main
# The following entry points should eventually be removed / replaced # The following entry points should eventually be removed / replaced
l2ss-hardware-device-template = tangostationcontrol.examples.HW_device_template:main l2ss-hardware-device-template = tangostationcontrol.examples.HW_device_template:main
......
from concurrent import futures
import grpc
import logging
from ._proto import observation_pb2
from ._proto import observation_pb2_grpc
from tangostationcontrol.common.lofar_logging import configure_logger, exception_to_str
from tangostationcontrol.common.proxy import create_proxy
logger = logging.getLogger()
TIMEOUT = 5000
PORT = 50051
class Observation(observation_pb2_grpc.ObservationServicer):
def StartObservation(
self, request: observation_pb2.StartObservationRequest, context
):
logger.info("Start observation")
try:
observation_control = create_proxy("STAT/ObservationControl/1", TIMEOUT)
observation_control.add_observation(request.configuration)
return observation_pb2.ObservationReply(success=True)
except Exception as e:
logger.exception(f"Starting observation failed: {exception_to_str(e)}")
return observation_pb2.ObservationReply(
success=False, exception=exception_to_str(e)
)
def StopObservation(self, request: observation_pb2.StopObservationRequest, context):
logger.info(f"Stop observation {request.observation_id}")
try:
observation_control = create_proxy("STAT/ObservationControl/1", TIMEOUT)
observation_control.stop_observation_now(request.observation_id)
return observation_pb2.ObservationReply(success=True)
except Exception as e:
logger.exception(f"Stopping observation failed: {exception_to_str(e)}")
return observation_pb2.ObservationReply(
success=False, exception=exception_to_str(e)
)
def main():
configure_logger()
logger.info(f"Start server on insecure port 0.0.0.0:{PORT}")
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
observation_pb2_grpc.add_ObservationServicer_to_server(Observation(), server)
server.add_insecure_port(f"0.0.0.0:{PORT}")
server.start()
logger.info(f"Server started, listening on port {PORT}")
server.wait_for_termination()
if __name__ == "__main__":
main()
...@@ -94,7 +94,9 @@ commands = ...@@ -94,7 +94,9 @@ commands =
[testenv:build] [testenv:build]
usedevelop = False usedevelop = False
commands = {envpython} -m build commands =
{envpython} -m grpc_tools.protoc -Itangostationcontrol/rpc/_proto=proto --python_out=. --pyi_out=. --grpc_python_out=. proto/observation.proto
{envpython} -m build
[testenv:docs] [testenv:docs]
envdir = {toxworkdir}/docs envdir = {toxworkdir}/docs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment