From dbcb09d3d476e1fe086adea3d5d4431e46ef6c11 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Tue, 23 May 2023 13:18:06 -0700 Subject: [PATCH] [Example] Move systemd socket activation example (#33221) --- .../sd_sock_act => systemd_socket_activation}/BUILD | 0 examples/cpp/systemd_socket_activation/README.md | 13 +++++++++++++ .../client.cc | 0 .../server.cc | 0 .../test.sh | 9 +++------ 5 files changed, 16 insertions(+), 6 deletions(-) rename examples/cpp/{features/sd_sock_act => systemd_socket_activation}/BUILD (100%) create mode 100644 examples/cpp/systemd_socket_activation/README.md rename examples/cpp/{features/sd_sock_act => systemd_socket_activation}/client.cc (100%) rename examples/cpp/{features/sd_sock_act => systemd_socket_activation}/server.cc (100%) rename examples/cpp/{features/sd_sock_act => systemd_socket_activation}/test.sh (78%) diff --git a/examples/cpp/features/sd_sock_act/BUILD b/examples/cpp/systemd_socket_activation/BUILD similarity index 100% rename from examples/cpp/features/sd_sock_act/BUILD rename to examples/cpp/systemd_socket_activation/BUILD diff --git a/examples/cpp/systemd_socket_activation/README.md b/examples/cpp/systemd_socket_activation/README.md new file mode 100644 index 00000000000..8c4182cf044 --- /dev/null +++ b/examples/cpp/systemd_socket_activation/README.md @@ -0,0 +1,13 @@ +gRPC systemd Socket Activation Example +================ + +This example shows how to use systemd's [socket-based activation](https://www.freedesktop.org/software/systemd/man/sd_listen_fds_with_names.html) with gRPC. + +### Build and run the example + +The simplest way to exercise this is via `test.sh`. It roughly does the following: + +* Creates a systemd socket-activated service. +* Builds the gRPC client & server. +* Reloads the systemd daemon. +* Runs the gRPC client, which in turn runs the gRPC server. diff --git a/examples/cpp/features/sd_sock_act/client.cc b/examples/cpp/systemd_socket_activation/client.cc similarity index 100% rename from examples/cpp/features/sd_sock_act/client.cc rename to examples/cpp/systemd_socket_activation/client.cc diff --git a/examples/cpp/features/sd_sock_act/server.cc b/examples/cpp/systemd_socket_activation/server.cc similarity index 100% rename from examples/cpp/features/sd_sock_act/server.cc rename to examples/cpp/systemd_socket_activation/server.cc diff --git a/examples/cpp/features/sd_sock_act/test.sh b/examples/cpp/systemd_socket_activation/test.sh similarity index 78% rename from examples/cpp/features/sd_sock_act/test.sh rename to examples/cpp/systemd_socket_activation/test.sh index 02c51cd2549..f7cd42ebc64 100755 --- a/examples/cpp/features/sd_sock_act/test.sh +++ b/examples/cpp/systemd_socket_activation/test.sh @@ -13,9 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Test structure borrowed with gratitude from -# https://github.com/grpc/grpc-go/tree/master/examples/features - # Run this script as root clean() { @@ -39,9 +36,9 @@ pass() { echo "SUCCESS: $1" } -bazel build --define=use_systemd=true //examples/cpp/features/sd_sock_act:all || fail "Failed to build sd_sock_act" -cp ../../../../bazel-bin/examples/cpp/features/sd_sock_act/server /tmp/greeter_server -cp ../../../../bazel-bin/examples/cpp/features/sd_sock_act/client /tmp/greeter_client +bazel build --define=use_systemd=true //examples/cpp/systemd_socket_activation:all || fail "Failed to build sd_sock_act" +cp ../../../../bazel-bin/examples/cpp/systemd_socket_activation/server /tmp/greeter_server +cp ../../../../bazel-bin/examples/cpp/systemd_socket_activation/client /tmp/greeter_client cat << EOF > /etc/systemd/system/sdsockact.service [Service]