canonical-ubuntu-qa team mailing list archive
-
canonical-ubuntu-qa team
-
Mailing list archive
-
Message #03607
[Merge] ~andersson123/autopkgtest-cloud:rabbitmq-cleanup-fix into autopkgtest-cloud:master
Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:rabbitmq-cleanup-fix into autopkgtest-cloud:master.
Requested reviews:
Canonical's Ubuntu QA (canonical-ubuntu-qa)
For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/463484
--
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:rabbitmq-cleanup-fix into autopkgtest-cloud:master.
diff --git a/mojo/rabbitmq-cleanup-setup b/mojo/rabbitmq-cleanup-setup
index 8fb4ea9..0eaeb40 100644
--- a/mojo/rabbitmq-cleanup-setup
+++ b/mojo/rabbitmq-cleanup-setup
@@ -8,26 +8,12 @@ machine=$(juju status --format=json rabbitmq-server | jq --monochrome-output --r
# set file names
service_name="maybe-restart-rabbitmq"
rabbitmq_mdir="/home/ubuntu/${service_name}"
+script_location="/home/$USER/autopkgtest-cloud/mojo/rabbitmq-scripts/maybe-restart-rabbitmq"
-##################################################################
-# Create script
-cat > /tmp/"${service_name}" << EOM
-#!/bin/sh
-
-set -e
-
-# Set a limit 2 GiB
-LIMIT=$((2 * 1024 * 1024 * 1024))
-
-if [ $(cat /sys/fs/cgroup/memory/system.slice/rabbitmq-server.service/memory.usage_in_bytes 2>/dev/null || echo 0) -ge $LIMIT ]; then
- echo "RabbitMQ uses too much memory, restarting"
- timeout 30 rabbitmq-diagnostics memory_breakdown || true
- systemctl restart rabbitmq-server.service
-fi
-
-EOM
-
-chmod +x /tmp/"${service_name}"
+# Remove files before re-creating them
+rm -f /tmp/maybe-restart-rabbitmq
+rm -f /tmp/maybe-restart-rabbitmq.service
+rm -f /tmp/maybe-restart-rabbitmq.timer
# Create service file
cat > /tmp/"${service_name}".service << EOM
@@ -53,13 +39,16 @@ WantedBy=multi-user.target
EOM
##################################################################
+# Remove existing files
+juju exec --machine "${machine}" "rm -rf ${rabbitmq_mdir}"
+
+##################################################################
# Create directory for files
juju exec --machine "${machine}" "mkdir -p ${rabbitmq_mdir}"
-
##################################################################
# Copy script to machine
-juju scp /tmp/"${service_name}" "${machine}":"${rabbitmq_mdir}/"
+juju scp "${script_location}" "${machine}":"${rabbitmq_mdir}/"
# Copy service to machine
juju scp /tmp/"${service_name}".service "${machine}":"${rabbitmq_mdir}/"
diff --git a/mojo/rabbitmq-scripts/maybe-restart-rabbitmq b/mojo/rabbitmq-scripts/maybe-restart-rabbitmq
new file mode 100755
index 0000000..249bdb0
--- /dev/null
+++ b/mojo/rabbitmq-scripts/maybe-restart-rabbitmq
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+# Set a limit 2 GiB
+LIMIT=$((2 * 1024 * 1024 * 1024))
+
+if [ $(cat /sys/fs/cgroup/memory/system.slice/rabbitmq-server.service/memory.usage_in_bytes 2>/dev/null || echo 0) -ge $LIMIT ]; then
+ echo "RabbitMQ uses too much memory, restarting"
+ timeout 30 rabbitmq-diagnostics memory_breakdown || true
+ systemctl restart rabbitmq-server.service
+fi