From 19b574b17155503f8c217e405836ed392e39a6e3 Mon Sep 17 00:00:00 2001 From: William Bezuidenhout Date: Wed, 6 Dec 2023 11:56:39 +0200 Subject: [PATCH] bazel: write docsite script to .bin (#58768) * bazel: write script to .bin you can't remove the script after it has started - even with a trap since sg gets killed before the trap is executed. * Update sg.config.yaml * add comment for docsite run script --- sg.config.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sg.config.yaml b/sg.config.yaml index bd8741de633..a2401365670 100644 --- a/sg.config.yaml +++ b/sg.config.yaml @@ -463,7 +463,20 @@ commands: docsite: description: Docsite instance serving the docs - cmd: bazel run --script_path=docsite_run.sh --noshow_progress --noshow_loading_progress //doc:serve && ./docsite_run.sh + env: + RUN_SCRIPT_NAME: .bin/bazel_run_docsite.sh + cmd: | + # We tell bazel to write out a script to run docsite and run that script via sg otherwise + # when we get a SIGINT ... bazel gets killed but docsite doesn't get killed properly. So we use --script_path + # which tells bazel to write out a script to run docsite, and let sg run that script rather, which means + # any signal gets propagated and docsite gets properly terminated. + # + # We also specifically put this in .bin, since that directory is gitignored, otherwise the run script is left + # around and currently there is no clean way to remove it - even using a bash trap doesn't work, since the trap + # never gets executed due to sg running the script. + bazel run --script_path=${RUN_SCRIPT_NAME} --noshow_progress --noshow_loading_progress //doc:serve + + ./${RUN_SCRIPT_NAME} syntax-highlighter: ignoreStdout: true