mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
* fix: Add `trap` to agent startup script to sleep on failure The Docker Terraform provider removes containers immediately on exit, making it difficult to debug a failed container start with Coder. This will sleep on exit and output a friendly log, which should assist with debugging failures. * Update provisionersdk/agent.go Co-authored-by: Mathias Fredriksson <mafredri@gmail.com> * Update provisionersdk/agent.go Co-authored-by: Mathias Fredriksson <mafredri@gmail.com> Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
22 lines
780 B
Bash
22 lines
780 B
Bash
#!/usr/bin/env sh
|
|
set -eux pipefail
|
|
trap 'echo === Agent script exited with non-zero code. Sleeping 24h to preserve logs... && sleep 86400' EXIT
|
|
BINARY_DIR=$(mktemp -d -t coder.XXXXXX)
|
|
BINARY_NAME=coder
|
|
BINARY_URL=${ACCESS_URL}bin/coder-linux-${ARCH}
|
|
cd "$BINARY_DIR"
|
|
if command -v curl >/dev/null 2>&1; then
|
|
curl -fsSL --compressed "${BINARY_URL}" -o "${BINARY_NAME}"
|
|
elif command -v wget >/dev/null 2>&1; then
|
|
wget -q "${BINARY_URL}" -O "${BINARY_NAME}"
|
|
elif command -v busybox >/dev/null 2>&1; then
|
|
busybox wget -q "${BINARY_URL}" -O "${BINARY_NAME}"
|
|
else
|
|
echo "error: no download tool found, please install curl, wget or busybox wget"
|
|
exit 1
|
|
fi
|
|
chmod +x $BINARY_NAME
|
|
export CODER_AGENT_AUTH="${AUTH_TYPE}"
|
|
export CODER_AGENT_URL="${ACCESS_URL}"
|
|
exec ./$BINARY_NAME agent
|