Pull config from env
This commit is contained in:
Родитель
fa05e7873d
Коммит
ff977c428a
11
README.md
11
README.md
|
@ -1,4 +1,11 @@
|
|||
# heroku-buildpack-lightstep-collector
|
||||
Heroku buildpack to run the lightstep collector in each dyno
|
||||
|
||||
Honestly not sure this even works yet.
|
||||
Heroku buildpack to run the lightstep collector in each dyno.
|
||||
|
||||
## Configuration
|
||||
|
||||
Configure this buildpack by setting configuration variables for your app. At minimum, you must set:
|
||||
- `COLLECTOR_SATELLITE_KEY`: the satellite requires this to function.
|
||||
- `COLLECTOR_PLAIN_PORT`: the satellite tries to bind to port 80 by default, which will not work with Heroku.
|
||||
|
||||
Additional configuration variables can be found [in LightStep's documentation](https://docs.lightstep.com/docs/docker-install-and-configure-satellites).
|
||||
|
|
45
bin/compile
45
bin/compile
|
@ -1,10 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
if [[ -n "$LS_BUILDPACK_DEBUG" ]]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
BUILD_DIR=$1
|
||||
CACHE_DIR=$2
|
||||
|
@ -14,14 +11,13 @@ BUILDPACK_DIR=$(cd "$(dirname "$0")"; cd ..; pwd)
|
|||
LS_DIR="$BUILD_DIR/.lightstep-collector"
|
||||
PROFILE_DIR="$BUILD_DIR/.profile.d"
|
||||
|
||||
VERSION="2020.09.24.05.22.16Z"
|
||||
VERSION="2021.01.26.23.02.36Z"
|
||||
CACHED_VERSION="$CACHE_DIR/lightstep-collector-$VERSION"
|
||||
|
||||
arrow() {
|
||||
echo '----->' "$@"
|
||||
}
|
||||
|
||||
fetch_lightstep() {
|
||||
if [ ! -f "$CACHED_VERSION" ]; then
|
||||
arrow "Installing LightStep collector ${VERSION}"
|
||||
wget \
|
||||
|
@ -34,48 +30,9 @@ fetch_lightstep() {
|
|||
else
|
||||
arrow "LightStep collector ${VERSION} found in cache"
|
||||
fi
|
||||
}
|
||||
|
||||
write_config() {
|
||||
for var in LS_API_KEY LS_POOL LS_SERVICE LS_BYTES_PER_PROJECT; do
|
||||
if [[ -f "$ENV_DIR/$var" ]]; then
|
||||
export "$var=$(cat "$ENV_DIR/$var")"
|
||||
fi
|
||||
done
|
||||
|
||||
LS_API_KEY=${LS_API_KEY:-badkey}
|
||||
LS_POOL=${LS_POOL:-heroku}
|
||||
LS_GUID="${LS_SERVICE:-heroku-service}-${DYNO:-unknown-dyno}"
|
||||
LS_BYTES_PER_PROJECT=${LS_BYTES_PER_PROJECT:-100000}
|
||||
cat <<EOF > "$LS_DIR/config.yaml"
|
||||
api_key: ${LS_API_KEY}
|
||||
pool: ${LS_POOL}
|
||||
guid: ${LS_GUID}
|
||||
babysitter_port: 8000
|
||||
plain_port: 8383
|
||||
admin:
|
||||
plain_port: 8080
|
||||
http:
|
||||
plain_port: 8181
|
||||
grpc:
|
||||
plain_port: 8282
|
||||
instrument:
|
||||
start_wait_time_limit: 30s
|
||||
reporter:
|
||||
bytes_per_project: ${LS_BYTES_PER_PROJECT}
|
||||
span_group_update_period: 2s
|
||||
EOF
|
||||
|
||||
}
|
||||
|
||||
install_lightstep() {
|
||||
mkdir -p "$LS_DIR"
|
||||
cp "$CACHED_VERSION/opt/lightstep/collector" "$LS_DIR/collector"
|
||||
|
||||
mkdir -p "$PROFILE_DIR"
|
||||
cp "$BUILDPACK_DIR/extra/lightstep-collector.sh" "$PROFILE_DIR/lightstep-collector.sh"
|
||||
}
|
||||
|
||||
fetch_lightstep
|
||||
install_lightstep
|
||||
write_config
|
||||
|
|
|
@ -2,5 +2,4 @@
|
|||
|
||||
ulimit -n $(ulimit -n -H)
|
||||
|
||||
LS_DIR="$HOME/.lightstep-collector"
|
||||
"$LS_DIR/collector" --collector_base_config="$LS_DIR/config.yaml" 2>&1 &
|
||||
"$HOME/.lightstep-collector/collector" 2>&1 &
|
||||
|
|
Загрузка…
Ссылка в новой задаче