AtlatestRepositoryapiary

apiary / tree / test / harnessenv-down.sh

1#!/usr/bin/env bash
2#
3# Tear down the throwaway enclave-server started by env-up.sh.
4#
5# Kills ONLY the PID recorded in state.env. Never a pattern match:
6# another harness may be running the same binary on this host, and an
7# agent session's own command line typically contains the task name it
8# would match on. See README.md.
9set -u
10RUN=${HARNESS_RUN:-/tmp/apiary-harness}
11[ -f "$RUN/state.env" ] || { echo "no $RUN/state.env -- nothing to stop"; exit 0; }
12. "$RUN/state.env"
13if kill -0 "$SERVER_PID" 2>/dev/null; then
14 kill "$SERVER_PID" && echo "killed enclave server pid=$SERVER_PID"
15else
16 echo "server pid=$SERVER_PID already gone"
17fi