From b778bb91265c97eba97bf787a945f6af0a85184f Mon Sep 17 00:00:00 2001 From: "Ware, Joseph (DLSLtd,RAL,LSCI)" Date: Mon, 25 Nov 2024 11:31:49 +0000 Subject: [PATCH] Move RabbitMQ startup into compose file --- .devcontainer/compose.yml | 10 +++++++ .../config.yml | 0 .../rabbitmq_setup/enabled_plugins | 0 docs/tutorials/quickstart.md | 26 ++++++++++++------- src/script/start_rabbitmq.sh | 16 ------------ 5 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 .devcontainer/compose.yml rename src/script/stomp_config.yml => .devcontainer/config.yml (100%) rename {src/script => .devcontainer}/rabbitmq_setup/enabled_plugins (100%) delete mode 100755 src/script/start_rabbitmq.sh diff --git a/.devcontainer/compose.yml b/.devcontainer/compose.yml new file mode 100644 index 000000000..312096f9b --- /dev/null +++ b/.devcontainer/compose.yml @@ -0,0 +1,10 @@ +services: + rabbitmq: + image: rabbitmq:management + container_name: 'rabbitmq' + ports: + - 5672:5672 + - 15672:15672 + - 61613:61613 + volumes: + - ./rabbitmq_setup/enabled_plugins:/etc/rabbitmq/enabled_plugins diff --git a/src/script/stomp_config.yml b/.devcontainer/config.yml similarity index 100% rename from src/script/stomp_config.yml rename to .devcontainer/config.yml diff --git a/src/script/rabbitmq_setup/enabled_plugins b/.devcontainer/rabbitmq_setup/enabled_plugins similarity index 100% rename from src/script/rabbitmq_setup/enabled_plugins rename to .devcontainer/rabbitmq_setup/enabled_plugins diff --git a/docs/tutorials/quickstart.md b/docs/tutorials/quickstart.md index 683800608..15394ec1a 100644 --- a/docs/tutorials/quickstart.md +++ b/docs/tutorials/quickstart.md @@ -4,15 +4,21 @@ Blueapi acts as a worker that can run bluesky plans against devices for a specif laboratory setup. It can control devices to collect data and export events to tell downstream services about the data it has collected. -## Start RabbitMQ +## Start Services -The worker requires a running instance of RabbitMQ. The easiest way to start it is - to execute the provided script: +The worker requires other infrastructure services running- these are captured in a [compose-spec](https://github.com/compose-spec/compose-spec/blob/main/spec.md) file: `.devcontainer/compose.yml`, and may later be started as part of building the devcontainer when [compatibility with podman is improved](https://github.com/devcontainers/cli/issues/863). +To run the services: ``` - src/script/start_rabbitmq.sh + # with docker + docker compose -f .devcontainer/compose.yml up + # or with podman-compose + podman-compose -f .devcontainer/compose.yml up ``` +This creates and configures: +- RabbitMQ with the rabbitmq_stomp plugin exposed at localhost:61613 + ## Start Worker To start the worker: @@ -21,24 +27,26 @@ To start the worker: blueapi serve ``` -The worker can also be started using a custom config file: +The worker can also be started with additional configuration from file: ``` blueapi --config path/to/file serve + # or + blueapi -c path/to/file serve ``` -An example of a config file that starts STOMP with default values can be found in: +A config file compatible with the services in the compose-spec above is included alongside it: ``` - src/script/stomp_config.yml + .devcontainer/config.yml ``` ## Test that the Worker is Running -Blueapi comes with a CLI so that you can query and control the worker from the terminal. +Blueapi comes with a CLI so that you can query and control the worker from the terminal, this should be passed the same config as the worker: ``` - blueapi controller plans + blueapi [--config path/to/file] controller plans ``` The above command should display all plans the worker is capable of running. diff --git a/src/script/start_rabbitmq.sh b/src/script/start_rabbitmq.sh deleted file mode 100755 index bc185b588..000000000 --- a/src/script/start_rabbitmq.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "$BASH_SOURCE[0]" )" &> /dev/null && pwd ) -RABBITMQ_VERSION="rabbitmq:management" -cmd1='run -it --rm --name rabbitmq -v '\ -$SCRIPT_DIR'/rabbitmq_setup/enabled_plugins:/etc/rabbitmq/enabled_plugins'\ -' -p 5672:5672 -p 15672:15672 -p 61613:61613 '$RABBITMQ_VERSION - -echo "Checking docker/podman installation" -if command -v docker &> /dev/null; then - docker $cmd1 -elif command -v podman &> /dev/null; then - podman $cmd1 -else - echo "Docker/Podman installation not found. Please install docker/podman." - exit 1 -fi