From 228f19e72bb9cf146cbf8c39c071f2d1db5a7dd3 Mon Sep 17 00:00:00 2001 From: Pierre Tessier Date: Mon, 18 Dec 2023 14:48:51 -0500 Subject: [PATCH] [chore] dev tooling: add restart-service (#1302) * add restart-service Signed-off-by: Pierre Tessier * comments are good Signed-off-by: Pierre Tessier * support service and SERVICE Signed-off-by: Pierre Tessier * add license Signed-off-by: Pierre Tessier * add license Signed-off-by: Pierre Tessier --------- Signed-off-by: Pierre Tessier --- Makefile | 8 ++++++++ restart-service.sh | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 restart-service.sh diff --git a/Makefile b/Makefile index e9340278b5..36fbc229c5 100644 --- a/Makefile +++ b/Makefile @@ -155,3 +155,11 @@ stop: docker compose down --remove-orphans --volumes @echo "" @echo "OpenTelemetry Demo is stopped." + + +# Use to rebuild and restart a single service component +# Example: make restart service=frontend +.PHONY: restart +restart: + # work with `service` or `SERVICE` as input + ./restart-service.sh ${service}${SERVICE} diff --git a/restart-service.sh b/restart-service.sh new file mode 100755 index 0000000000..5f80919dbe --- /dev/null +++ b/restart-service.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +# This script is used to build, then restart the newly built service container. It does this by forcing a full stop +# and removal of the container, then recreating it. This is useful for development, as it ensures the latest code +# is running in the container. + +if [ -z "$1" ] +then + echo "Please provide a service name" + exit 1 +fi + +docker compose build "$1" +docker compose stop "$1" +docker compose rm --force "$1" +docker compose create "$1" +docker compose start "$1"