cmvr-es/cmvr-es/management
2026-12-04 13:47:05 +08:00
..
CMakeLists.txt feat(management): add independent configuration and process manager 2026-12-04 13:47:05 +08:00
manager_ctl.cpp feat(management): add independent configuration and process manager 2026-12-04 13:47:05 +08:00
manager_main.cpp feat(management): add independent configuration and process manager 2026-12-04 13:47:05 +08:00
manager_test.cpp feat(management): add independent configuration and process manager 2026-12-04 13:47:05 +08:00
README.md feat(management): add independent configuration and process manager 2026-12-04 13:47:05 +08:00
start_all.sh feat(management): add independent configuration and process manager 2026-12-04 13:47:05 +08:00
test_manager.py feat(management): add independent configuration and process manager 2026-12-04 13:47:05 +08:00

Independent cmvr-es management

cmvr_manager is a separate gRPC process. Device RPCs remain in cmvr_es. It uses the existing executable and configuration layout:

output/bin/cmvr_es
output/bin/cmvr_manager
output/bin/config/...
output/lib/...

Build with the existing CMake build directory:

cmake --build cmake-build-debug --target cmvr_manager
cmake --install cmake-build-debug/cmvr-es/management

When first installing a newly generated management protocol, install the matching libproto.so in output/lib as well. A normal full project install does this. Installing defaults now preserves existing deployed configuration files and adds only missing files. Models retain their existing install location.

Run as the ordinary deployment user:

cd output/bin
./cmvr_manager --listen 0.0.0.0:50053

To start both programs together, run output/bin/start_all.sh as the deployment user. It starts/reuses the matching management endpoint and requests cmvr_es startup over gRPC, so cmvr_es remains owned by the manager. Repeated execution does not restart either process. CMVR_MANAGEMENT_PORT overrides port 50053. Logs append to the existing output/bin/cmvr_manager.log.

output/bin/cmvr_manager_ctl status queries status; start, stop, and restart use the same typed management gRPC interface. An application started outside the manager must first be stopped through its original launcher.

Initialize bus hardware before starting cmvr_es, using the existing repository layout:

./scripts/start_hardware.sh --ethercat-iface enp2s0 --check
./scripts/start_hardware.sh --ethercat-iface enp2s0
./output/bin/start_all.sh

The hardware script is installed in the repository's existing scripts directory. It discovers currently present CAN interfaces, uses the existing CAN script's 1 Mbps default. EtherCAT always requires an explicit --ethercat-iface IFACE, including in --check mode; there is no fallback from configuration or environment. --can-only does not need an EtherCAT interface. --ethercat-only, repeatable --can-iface, and --bitrate are available. It requests sudo only for actual initialization. It refuses a normal-network interface and refuses hardware reinitialization while cmvr_es is running. Existing CAN links at the requested rate and an existing EtherCAT master on the selected MAC are kept running. Changing a running CAN link's bitrate requires --reconfigure-can.

In these examples enp2s0 is only an example: pass the actual dedicated port. On 234, the existing EtherCAT config names enp2s0; both Ethernet ports use IgH's igc driver. At script creation there were no CAN interfaces and both Ethernet ports had no carrier. The script was checked without altering network interfaces; real bus communication requires connecting the hardware and confirming the dedicated EtherCAT port. No drive enable or movement is performed by this script.

The default executable and working directory are the manager's own directory. --bin-dir selects another existing deployment directory for isolated testing. No shell commands, executable paths or arbitrary filenames are accepted over RPC. This is the same trusted-LAN, insecure-gRPC transport as the existing device service; it does not introduce a public internet endpoint.

GetStatus reports process existence/ownership, not device readiness. A running process started by CLion or another launcher is detected but not stopped or adopted. Stop it in the original launcher before starting it through the manager. STOP sends SIGTERM and waits up to 30 seconds; timeout never escalates to SIGKILL and cancels RESTART. Process startup errors remain visible through management RPC and the manager's redirected output. Stop the managed child before stopping the manager itself; this initial implementation does not provide boot autostart or adopt an orphaned child after the manager is killed.

Configuration RPCs access existing .pb.txt files inside the existing config directory. Writes check protobuf syntax, known fields/enums, message type and configuration-file references. The root config must retain logger, device manager and task manager references. Writes require the revision returned by ReadConfig and use a flushed temporary file beside the destination followed by rename. The temporary file is not a server-side draft. The editor stores drafts on the Windows client in data/management_drafts.json, keyed by endpoint and filename. Saving does not automatically restart the application. File validation does not certify device parameters or hardware readiness; runtime/device initialization continues to perform those checks.

Protocol: protos/cmvr/management/manager.proto.

Tests:

cmake --build cmake-build-debug --target cmvr_manager cmvr_manager_test
python3 cmvr-es/management/test_manager.py
cmake-build-debug/cmvr-es/management/cmvr_manager_test 127.0.0.1:50053 --read-only

The fixture test uses a temporary directory and replacement child process. The --lifecycle mode is specifically for a deployment whose cmvr_es is stopped and whose enabled tasks/devices have been checked first. It saves identical config bytes, starts/restarts/stops the real program, checks control gRPC on 50052, and leaves it stopped. Do not use that mode against a deployment in active operation.