Page MenuHomePhabricator

[Nix] Add rabbitmq-up command
ClosedPublic

Authored by jon on Aug 24 2022, 10:47 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 9:38 PM
Unknown Object (File)
Sun, Dec 15, 5:22 AM
Unknown Object (File)
Thu, Dec 5, 1:16 AM
Unknown Object (File)
Fri, Nov 22, 8:00 AM
Unknown Object (File)
Fri, Nov 22, 8:00 AM
Unknown Object (File)
Fri, Nov 22, 8:00 AM
Unknown Object (File)
Fri, Nov 22, 8:00 AM
Unknown Object (File)
Fri, Nov 22, 8:00 AM
Subscribers

Details

Reviewers
max
abosh
varun
atul
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rCOMM449de39cde50: [Nix] Add rabbitmq-up command
Summary

Add rabbitmq-up command for creation of
a local user service for development of tunnelbroker.

https://linear.app/comm/issue/ENG-1696

Test Plan
# Stop any existing rabbitmq services if they exist

nix develop
nix run .#rabbitmq-up

# Should show that it's bound to 5672, and listening
tail -f $HOME/.local/share/RabbitMQ/logs/comm.log

# Running it again should do nothing
nix run .#rabbitmq-up

# Cleanup services, optional
pkill rabbitmq-server beam.smp

Diff Detail

Repository
rCOMM Comm
Branch
jonringer/rabbitmq
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Owners added a reviewer: Restricted Owners Package.Aug 24 2022, 10:47 AM

Clean up comment about how rabbitmq is configured

Reference where rabbitmq environment variables come from

i think max should be blocking here since he knows the most about rabbit mq

Closer and closer to 100% support for the Nix workflow!!

Bump @max looks like you're a blocking reviewer here

atul requested changes to this revision.Oct 7 2022, 11:14 AM
atul@atuls-MacBook-Pro comm % nix develop
Existing Redis instance found outside of nix environment
Please stop existing services and attempt 'nix develop' again
Existing MariaDB instance found outside of nix environment
Please stop existing services and attempt 'nix develop' again
Welcome to Comm dev environment! :)
atuls-MacBook-Pro:comm atul$ nix run .#rabbitmq-up
Starting RabbitMQ
/nix/store/b5prjzmy2lshrl2dq6bdbf2hld9km8sw-start_comm_daemon.sh: line 20: /Users/atul/.local/share/RabbitMQ/rabbitmq.pid: No such file or directory
atuls-MacBook-Pro:comm atul$ View RabbitMQ logs: tail -f /Users/atul/.local/share/RabbitMQ/logs/comm.log
Kill RabbitMQ server: pkill rabbitmq-server beam.smp
/nix/store/9rqvrg9ykyzqjk8xlsbsnyr394n3mi9v-rabbitmq-init/bin/rabbitmq-init: line 16: /Users/atul/.local/share/RabbitMQ/logs/startup.log: No such file or directory
This revision now requires changes to proceed.Oct 7 2022, 11:14 AM
atul requested changes to this revision.Oct 10 2022, 6:49 PM
atul@atuls-MacBook-Pro comm % nix develop
warning: Using saved setting for 'extra-trusted-public-keys = comm.cachix.org-1:70RF31rkmCEhQ9HrXA2uXcpqQKGcUK3TxLJdgcUCaA4=' from ~/.local/share/nix/trusted-settings.json.
warning: Using saved setting for 'extra-trusted-substituters = https://comm.cachix.org' from ~/.local/share/nix/trusted-settings.json.
Restored session: Mon Oct 10 21:48:30 EDT 2022
Existing MariaDB instance found outside of nix environment
Please stop existing services and attempt 'nix develop' again
Existing Redis instance found outside of nix environment
Please stop existing services and attempt 'nix develop' again
Welcome to Comm dev environment! :)
atuls-MacBook-Pro:comm atul$ nix run .#rabbitmq-up
Starting RabbitMQ
atuls-MacBook-Pro:comm atul$ /nix/store/nh66479vxwclh2b3c4piipa4ygn3r8jw-rabbitmq-init/bin/rabbitmq-init: line 8: RABBITMQ_LOGS_BASE: unbound variable
This revision now requires changes to proceed.Oct 10 2022, 6:49 PM

Fix typo in environment variable

going to refactor the startup logic to a separate script

Refactor most of the logic to be a shell script

Make older shellcheck happy

In D4948#171207, @jon wrote:

Make older shellcheck happy

Do we need to update something on CI side?

Do we need to update something on CI side?

Ubuntu shellcheck is 0.7.1, nix uses 0.8.

The older one seems to error if you set a variable, then use it later without the # shellcheck source=... line.

Not sure how much we can do, unless you just want to use nixpkgs' shellcheck.

Going to accept but leave @max as blocking since he has the most context on RabbitMQ.

flake.nix
16

Trusting you on this... I really have no idea how to parse this

Might be worth adding a comment? (unless it's obvious to someone who is reasonably familiar with Nix)

max added inline comments.
scripts/source_development_defaults.sh
16

Maybe we should add a default username and password for the local RabbitMQ? :

RABBITMQ_DEFAULT_PASS=comm
RABBITMQ_DEFAULT_USER=comm

And then we can use the same credentials for the dev default config file for the Tunnelbroker. So the devs will not touch the config and RabbitMQ admin to start.

This revision is now accepted and ready to land.Nov 29 2022, 4:20 AM
jon marked 2 inline comments as done.

Add default user and pass

flake.nix
16

self is a reference to the flake. toString forces the flake to render as a string representing the path in the nix store. So we have a way to reference the entire code base.

This is needed because the scripts assume they are co-located to each other. One optimization for this might just be adding the scripts directory only... Then we don't have reference the entire code base.

scripts/source_development_defaults.sh
16

Sounds good to me, I just ran rabbitmq enough to see that it starts without erroring.

This revision was automatically updated to reflect the committed changes.