Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

agent-conf.json file violates twelve-factor methodology of Heroku apps #46

Open
hheimbuerger opened this issue Apr 7, 2016 · 1 comment

Comments

@hheimbuerger
Copy link

I'm running an app on Heroku, which is a PaaS built upon the twelve-factor methodology.

Currently, the agent-conf.json file links my codebase to a specific instance of Librato. This violates a core concept of twelve-factor, namely the strict separation of configuration from code:

Apps sometimes store config as constants in the code. This is a violation of twelve-factor, which requires strict separation of config from code. Config varies substantially across deploys, code does not.

As the twelve-factor page I linked to earlier describes in more detail and much more clearly than I ever could, this is a problem because I'm deploying the same codebase to various instances, in my case production, staging, various demo instances for sales as well as a review app for each feature branch.

Please provide and document a way to support a maintainable Heroku setup, following the twelve-factor methodology.

@hheimbuerger hheimbuerger changed the title agent-conf.json file violates twelve-factor methodology for Heroku apps agent-conf.json file violates twelve-factor methodology of Heroku apps Apr 7, 2016
@hheimbuerger
Copy link
Author

I have multiple Heroku apps, representing different stages in the apps lifecycle: production, staging, reviews, etc.
My main interest was to selectively enable Librato for some Heroku apps (production) and have it completely disabled (i.e. the instrumention being a noop) on all other apps (staging, review, etc.).

I really wish this was just built into librato-python-web, but for now I've built my own wrapper script as a workaround:

bin/librato-wrapper in my Heroku codebase:

#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset

if [ "${LIBRATO_ENABLED:-}" = "true" ]
then
    echo "Found LIBRATO_ENABLED, enabling Librato instrumentation..."
    exec librato-launch "$@"
else
    echo "Skipping Librato instrumentation as LIBRATO_ENABLED was not set."
    exec "$@"
fi

(I'm not a bash expert, so suggestions are very welcome. I'm specifically hoping that this doesn't break Heroku's process watching and restarting. I've made the mistake of using && in my Procfile before and it took me months to track that down.)

My Procfile looks like this:

web: bin/librato-wrapper gunicorn myapp.wsgi --bind 0.0.0.0:$PORT ...

Now the librato-launch instrumentation is only run when the environment variable LIBRATO_ENABLED is set to true (in my case: only in production) and is skipped in all other cases.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant