Page MenuHomePhabricator

D4948.id17474.diff
No OneTemporary

D4948.id17474.diff

diff --git a/nix/dev-shell.nix b/nix/dev-shell.nix
--- a/nix/dev-shell.nix
+++ b/nix/dev-shell.nix
@@ -30,6 +30,7 @@
, pkg-config
, protobuf_3_15_cmake
, python3
+, rabbitmq-server
, redis
, redis-up
, rustc
@@ -72,6 +73,7 @@
pkg-config
protobuf_3_15_cmake
grpc
+ rabbitmq-server # runtime service
] ++ lib.optionals stdenv.isDarwin [
cocoapods # needed for ios
];
diff --git a/nix/overlay.nix b/nix/overlay.nix
--- a/nix/overlay.nix
+++ b/nix/overlay.nix
@@ -107,6 +107,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;
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,43 @@
+{ lib
+, rabbitmq-server
+, writeShellApplication
+}:
+
+let
+ # Use small script executed by bash to have a normal shell environment.
+ rabbitmq-entrypoint = writeShellApplication {
+ name = "rabbitmq-init";
+ text = ''
+ # RabbitMQ is mostly configured through environment variables
+ # located in scripts/source_development_defaults.sh
+ mkdir -p "$RABBITMQ_LOGS_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}/bin/rabbitmq-server" \
+ > "$RABBITMQ_LOG_BASE/startup.log"
+ '';
+ };
+
+# 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
+in writeShellApplication {
+ name = "rabbitmq-up";
+ text = ''
+ RABBITMQ_HOME=''${XDG_DATA_HOME:-$HOME/.local/share}/RabbitMQ
+ RABBITMQ_PIDFILE=''${RABBITMQ_HOME}/rabbitmq.pid
+
+ "${../scripts/start_comm_daemon.sh}" \
+ rabbitmq-server \
+ RabbitMQ \
+ "${rabbitmq-entrypoint}/bin/rabbitmq-init" \
+ "$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
@@ -12,3 +12,13 @@
export MYSQL_UNIX_PORT="$MARIADB_DIR"/mysql.sock
export ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}
fi
+
+# User defaults of
+# https://www.rabbitmq.com/configure.html#supported-environment-variables
+export RABBITMQ_NODENAME=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

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 5:28 AM (17 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693657
Default Alt Text
D4948.id17474.diff (3 KB)

Event Timeline