From 5abe34a29f734bc87e05852fabf9b4caf27f4a22 Mon Sep 17 00:00:00 2001 From: Raymond Fan Date: Mon, 4 Nov 2024 15:08:01 +0000 Subject: [PATCH] Include convenience bash script for running rabbit mq locally (#668) fix #615 --- docs/tutorials/dev-run.md | 2 +- docs/tutorials/quickstart.md | 20 ++++++++++++-------- src/script/rabbitmq_setup/enabled_plugins | 1 + src/script/start_rabbitmq.sh | 16 ++++++++++++++++ src/script/stomp_config.yml | 7 +++++++ 5 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 src/script/rabbitmq_setup/enabled_plugins create mode 100755 src/script/start_rabbitmq.sh create mode 100644 src/script/stomp_config.yml diff --git a/docs/tutorials/dev-run.md b/docs/tutorials/dev-run.md index 308253a96..429210901 100644 --- a/docs/tutorials/dev-run.md +++ b/docs/tutorials/dev-run.md @@ -10,7 +10,7 @@ Ensure you are inside your virtual environment: source venv/bin/activate ``` -You will need to follow the instructions for setting up ActiveMQ as in [run cli instructions](../how-to/run-cli.md). +You will need to follow the instructions for setting up RabbitMQ as in [run cli instructions](../how-to/run-cli.md). The worker will be available from the command line (`blueapi serve`), but can be started from vscode with additional debugging capabilities. diff --git a/docs/tutorials/quickstart.md b/docs/tutorials/quickstart.md index 1eb1c42b8..683800608 100644 --- a/docs/tutorials/quickstart.md +++ b/docs/tutorials/quickstart.md @@ -4,17 +4,13 @@ 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 ActiveMQ +## Start RabbitMQ -The worker requires a running instance of ActiveMQ, the simplest -way to start it is to run it via a container: +The worker requires a running instance of RabbitMQ. The easiest way to start it is + to execute the provided script: ``` - docker run -it --rm --net host rmohr/activemq:5.15.9-alpine -``` - -``` - podman run -it --rm --net host rmohr/activemq:5.15.9-alpine + src/script/start_rabbitmq.sh ``` ## Start Worker @@ -31,6 +27,12 @@ The worker can also be started using a custom config file: blueapi --config path/to/file serve ``` +An example of a config file that starts STOMP with default values can be found in: + +``` + src/script/stomp_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. @@ -41,4 +43,6 @@ Blueapi comes with a CLI so that you can query and control the worker from the t The above command should display all plans the worker is capable of running. + + See also [full cli reference](../reference/cli.md) diff --git a/src/script/rabbitmq_setup/enabled_plugins b/src/script/rabbitmq_setup/enabled_plugins new file mode 100644 index 000000000..454685a05 --- /dev/null +++ b/src/script/rabbitmq_setup/enabled_plugins @@ -0,0 +1 @@ +[rabbitmq_management,rabbitmq_prometheus,rabbitmq_stomp]. \ No newline at end of file diff --git a/src/script/start_rabbitmq.sh b/src/script/start_rabbitmq.sh new file mode 100755 index 000000000..bc185b588 --- /dev/null +++ b/src/script/start_rabbitmq.sh @@ -0,0 +1,16 @@ +#!/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 diff --git a/src/script/stomp_config.yml b/src/script/stomp_config.yml new file mode 100644 index 000000000..99ff4ad63 --- /dev/null +++ b/src/script/stomp_config.yml @@ -0,0 +1,7 @@ +--- +stomp: + host: "localhost" + port: 61613 + auth: + username: "guest" + password: "guest"