caenHV / caen_tools

Set of microservices for CAEN management (WebService, DeviceBackend, SystemCheck, Monitor)
0 stars 0 forks source link

CAEN Microservices

A set of microservices implementating the CAEN management architecture

Basic layout

The scheme of microservices interaction looks like (the arrows display requests directions):

List of microservices

WebService

Provides a web interface to the user and defines REST API. Contains web frontend and web backend.

DeviceBackend

Executes commands from other microservices on the CAEN device itself

MonitorService

Stores device parameters in the database and sends to Online DataBase (ODB)

SystemCheck

A service cyclically running scenarios of interaction with other microservices (so called scripts) that inspect the device parameters, send the availability status to MChS, transfer parameters from DeviceBackend to MonitorService, maintain the target voltage and interlock following (if needed)

Environment setting

As shown in the figure above, the current version of the system is running on a single machine (dq11), but all the services are located in their own docker containers and connected using docker compose.

The complete environment setup instructions can be found in the separate environment repository.

Development

There are several advices to quickly start the development process of this project.

Quick start

1) Prerequests:

2) Clone the repository with submodules (it will be frontend in this case)

git clone --recursive https://github.com/caenHV/caen_tools.git

3) Prepare and run virtual environment

cd caen_tools
python -m venv ./venv
source venv/bin/activate

4) Install development version of the caen_tools

pip install -e .[webservice]

create an empty directory to prevent crash of the webservice (until you build frontend)

mkdir -p caen_tools/WebService/frontend/build/static

5) Now it's possible to run microservices that you need by the following commands:

4) Optional: build frontend

cd caen_tools/caen_tools/WebService/frontend/
npm install package.json
export REACT_APP_CAEN=production && npm run build

if all is ok, you'll see the build folder in current directory and when you start the web server, you will see the main frontend page http://localhost:8000

Build package

if you want to build your own whl locally, you can do that.

Github actions

If you work with github repository, it supports automatic build on push of the tag.

Suppose, that you already pushed all your commits into the remote github repository and want to get build whl file, so:

git fetch origin --tags # fetch tags from remote origin repo 
git tag v2.2.7-experimental # create your own tag of the current commit 
git push origin --tags

Running

to quickly try this module you need download .whl file from latest release and then

python -m venv ./venv # create virtual environment
source venv/bin/activate # activate it
pip install "<filename>.whl[webservice]" # install this package

Run all of the microservices

caen_device_backend &
caen_monitor &
caen_system_check &
caen_webservice &

Go to http://localhost:8000

To simply close all of these microservices, run the following command in the other console window (this command will kill all processes whose name starting with caen_)

pkill -f caen_

Helpful links