0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-22 17:24:15 +01:00
posthog/bin/plugin-server
James Greenhill a8de2ac587
plugins debug (#2803)
* checkin

* Don't run yarn silently for plugin-server
2020-12-16 16:35:19 -08:00

37 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# Keys to export from django settings.py
KEYS="DATABASE_URL REDIS_URL PLUGINS_CELERY_QUEUE CELERY_DEFAULT_QUEUE KAFKA_HOSTS EE_ENABLED BASE_DIR PLUGINS_RELOAD_PUBSUB_CHANNEL"
# Export $CONFIG to posthog-plugin-server
export CONFIG=`python manage.py print_settings --format json --indent 0 $KEYS 2> /dev/null | tr -d '\n' | sed 's/\n$//'`
# On _Heroku_, the $WEB_CONCURRENCY env contains suggested number of workers per dyno.
# Unfortunately we are running a NodeJS app, yet get the value for the "python" buildpack.
# Thus instead of using this env directly, calculate the real concurrency from $DYNO_RAM.
# Python: https://github.com/heroku/heroku-buildpack-python/blob/main/vendor/WEB_CONCURRENCY.sh
# NodeJS: https://devcenter.heroku.com/articles/node-concurrency#common-runtime
if [[ -n "${DYNO_RAM}" ]]; then
# One worker for 512MB of RAM, rounding up
export WORKER_CONCURRENCY=$(( ($DYNO_RAM - 1) / 512 + 1 ))
fi
cd plugins
yarn --frozen-lockfile
if [ $? -ne 0 ]; then
echo "Yarn failed!"
exit 1
fi
while true; do
# Run: posthog-plugin-server
yarn --silent start
echo ""
echo "🔴 Plugin server crashed!"
echo "⌛️ Waiting 2 seconds before restarting!"
echo ""
sleep 2
done