Page MenuHomePhabricator

D4948.diff
No OneTemporary

D4948.diff

diff --git a/flake.nix b/flake.nix
--- a/flake.nix
+++ b/flake.nix
@@ -13,6 +13,7 @@
localOverlay = import ./nix/overlay.nix;
overlays = [
localOverlay
+ (_: _: { commSrc = toString self; } )
];
# Since we build for many systems (e.g. aarch64, x86_64-linux), we
diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix
--- a/nix/dev-shell.nix
+++ b/nix/dev-shell.nix
@@ -32,6 +32,7 @@
, pkg-config
, protobuf_3_15_cmake
, python3
+, rabbitmq-server
, redis
, redis-up
, rustup
@@ -82,6 +83,7 @@
pkg-config
protobuf_3_15_cmake
grpc
+ rabbitmq-server # runtime service
] ++ lib.optionals stdenv.isDarwin [
cocoapods # needed for ios
bundler
diff --git a/nix/overlay.nix b/nix/overlay.nix
--- a/nix/overlay.nix
+++ b/nix/overlay.nix
@@ -89,6 +89,8 @@
];
});
+ rabbitmq-up = prev.callPackage ./rabbitmq-up-mac.nix { };
+
# Ensure that yarn is using the pinned version
yarn = prev.yarn.override (_: {
nodejs = final.nodejs-16_x-openssl_1_1;
diff --git a/nix/rabbitmq-up-mac.nix b/nix/rabbitmq-up-mac.nix
new file mode 100644
--- /dev/null
+++ b/nix/rabbitmq-up-mac.nix
@@ -0,0 +1,27 @@
+{ lib
+, rabbitmq-server
+, writeShellApplication
+, commSrc
+}:
+
+# writeShellApplication is a "writer helper" which
+# will create a shellchecked executable shell script located in $out/bin/<name>
+# This shell script will be used to allow for impure+stateful actions
+writeShellApplication {
+ name = "rabbitmq-up";
+ runtimeInputs = [ rabbitmq-server ];
+ text = ''
+ RABBITMQ_HOME=''${XDG_DATA_HOME:-$HOME/.local/share}/RabbitMQ
+ RABBITMQ_PIDFILE=''${RABBITMQ_HOME}/rabbitmq.pid
+
+ "${commSrc}/scripts/start_comm_daemon.sh" \
+ beam.smp \
+ RabbitMQ \
+ "${commSrc}/scripts/start_rabbitmq.sh" \
+ "$RABBITMQ_PIDFILE"
+
+ # Explicitly exit this script so the parent shell can determine
+ # when it's safe to return control of terminal to user
+ exit 0
+ '';
+}
diff --git a/scripts/source_development_defaults.sh b/scripts/source_development_defaults.sh
--- a/scripts/source_development_defaults.sh
+++ b/scripts/source_development_defaults.sh
@@ -11,6 +11,18 @@
export ANDROID_HOME="${ANDROID_HOME:-$HOME/Library/Android/sdk}"
fi
+# User defaults of
+# https://www.rabbitmq.com/configure.html#supported-environment-variables
+export RABBITMQ_NODENAME=comm
+export RABBITMQ_DEFAULT_PASS=comm
+export RABBITMQ_DEFAULT_USER=comm
+export RABBITMQ_HOME=${XDG_DATA_HOME:-$HOME/.local/share}/RabbitMQ
+export RABBITMQ_MNESIA_BASE=${RABBITMQ_HOME}/mnesia
+export RABBITMQ_LOG_BASE=${RABBITMQ_HOME}/logs
+export RABBITMQ_LOGS=${RABBITMQ_LOG_BASE}/comm.log
+export RABBITMQ_PLUGINS_EXPAND_DIR=${RABBITMQ_HOME}/plugins_expand
+export RABBITMQ_PID_FILE=${RABBITMQ_HOME}/rabbitmq.pid
+
export PATH="$PATH":"$ANDROID_HOME"/emulator:"$ANDROID_HOME"/tools
export PATH="$PATH":"$ANDROID_HOME"/tools/bin:"$ANDROID_HOME"/platform-tools
diff --git a/scripts/start_rabbitmq.sh b/scripts/start_rabbitmq.sh
new file mode 100755
--- /dev/null
+++ b/scripts/start_rabbitmq.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+set -eou pipefail
+
+if ! command -v rabbitmq-server > /dev/null; then
+ echo "Please install rabbitmq-server or run 'nix develop'" >&2
+ exit 1
+fi
+
+SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd -P)
+
+# shellcheck source=/dev/null
+source "${SCRIPT_DIR}/source_development_defaults.sh"
+
+# RabbitMQ is mostly configured through environment variables
+# located in scripts/source_development_defaults.sh
+mkdir -p "$RABBITMQ_LOG_BASE"
+
+echo "View RabbitMQ logs: tail -f $RABBITMQ_LOGS" >&2
+echo "Kill RabbitMQ server: pkill rabbitmq-server beam.smp" >&2
+
+# 'exec' allows for us to replace bash process with RabbitMQ
+exec rabbitmq-server > "$RABBITMQ_LOG_BASE/startup.log"

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 12:15 AM (18 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692925
Default Alt Text
D4948.diff (3 KB)

Event Timeline