Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include convenience bash script for running rabbit mq locally #668

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/tutorials/dev-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 12 additions & 8 deletions docs/tutorials/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Relm-Arrowny marked this conversation as resolved.
Show resolved Hide resolved
```

## Start Worker
Expand All @@ -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
```

Comment on lines +30 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should: As above with ActiveMQ vs RabbitMQ, if we're going to make rabbitMQ the default for new users then maybe this should be the default config?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be, but I changed it. I think it's important for a complete beginner to clone -> build -> run with no extra steps, because once you add 1 extra step it's very easy to get into a "just one more..." mentality. The message bus is an optional feature that adds rich feedback and that we use in production, but configuring it is part 2 of the tutorial.

## Test that the Worker is Running

Blueapi comes with a CLI so that you can query and control the worker from the terminal.
Expand All @@ -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)
3 changes: 3 additions & 0 deletions src/script/rabbitmq_setup/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM rabbitmq:3.13.2-management
RUN rabbitmq-plugins enable rabbitmq_stomp
COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
10 changes: 10 additions & 0 deletions src/script/rabbitmq_setup/rabbitmq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
loopback_users = none
listeners.tcp.default = 5672
default_pass = guest
default_user = guest
hipe_compile = false
management.listener.port = 15672
management.listener.ssl = false
stomp.listeners.tcp.1 = 61613
stomp.default_user = guest
stomp.default_pass = guest
16 changes: 16 additions & 0 deletions src/script/start_rabbitmq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "$BASH_SOURCE[0]" )" &> /dev/null && pwd )
cmd1='build -t rabbitmq-stomp '$SCRIPT_DIR'/rabbitmq_setup/.'
cmd2='run -p 5672:5672 -p 15672:15672 -p 61613:61613 rabbitmq-stomp'

echo "Checking docker/podman installation"
if command -v docker &> /dev/null; then
docker $cmd1
docker $cmd2
elif command -v podman &> /dev/null; then
podman $cmd1
podman $cmd2
else
echo "Docker/Podman installation not found. Please install docker/podman."
exit 1
fi
7 changes: 7 additions & 0 deletions src/script/stomp_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
stomp:
host: "localhost"
port: 61613
auth:
username: "guest"
password: "guest"
Loading