Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8855561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:09:51+00:00 2026-06-14T14:09:51+00:00

I have a Python application that is set up using the new New Relic

  • 0

I have a Python application that is set up using the new New Relic configuration variables in the dotcloud.yml file, which works fine.

However I want to run a sandbox instance as a test/staging environment, so I want to be able to set the environment of the newrelic agent so that it uses the different configuration sections of the ini configuration. My dotcloud.yml is set up as follows:

www:
    type: python
    config:
        python_version: 'v2.7'
        enable_newrelic: True
    environment:
        NEW_RELIC_LICENSE_KEY: *****************************************
        NEW_RELIC_APP_NAME: Application Name
        NEW_RELIC_LOG: /var/log/supervisor/newrelic.log
        NEW_RELIC_LOG_LEVEL: info
        NEW_RELIC_CONFIG_FILE: /home/dotcloud/current/newrelic.ini 

I have custom environment variables so that the sanbox is set as “test” and the live application is set to “production”

I am then calling the following in my uswsgi.py

NEWRELIC_CONFIG = os.environ.get('NEW_RELIC_CONFIG_FILE')
ENVIRONMENT = os.environ.get('MY_ENVIRONMENT', 'test')

newrelic.agent.initialize(NEWRELIC_CONFIG, ENVIRONMENT)

However the dotcloud instance is already enabling newrelic because I get this in the uwsgi.log file:

Sun Nov 18 18:50:12 2012 - unable to load app 0 (mountpoint='') (callable not found or import error)
Traceback (most recent call last):
  File "/home/dotcloud/current/wsgi.py", line 15, in <module>
    newrelic.agent.initialize(NEWRELIC_CONFIG, ENVIRONMENT)
  File "/opt/ve/2.7/local/lib/python2.7/site-packages/newrelic-1.8.0.13/newrelic/config.py", line 1414, in initialize
    log_file, log_level)
  File "/opt/ve/2.7/local/lib/python2.7/site-packages/newrelic-1.8.0.13/newrelic/config.py", line 340, in _load_configuration
    'environment "%s".' % (_config_file, _environment))
newrelic.api.exceptions.ConfigurationError: Configuration has already been done against differing configuration file or environment. Prior configuration file used was "/home/dotcloud/current/newrelic.ini" and environment "None".

So it would seem that the newrelic agent is being initialised before uwsgi.py is called.

So my question is:

Is there a way to initialise the newrelic environment?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:09:51+00:00Added an answer on June 14, 2026 at 2:09 pm

    The easiest way to do this, without changing any code would be to do the following.

    Create a new sandbox app on dotCloud (see http://docs.dotcloud.com/0.9/guides/flavors/ for more information about creating apps in sandbox mode)

    $ dotcloud create -f sandbox  <app_name>
    

    Deploy your code to the new sandbox app.

    $ dotcloud push
    

    Now you should have the same code running in both your live and sandbox apps. But because you want to change some of the ENV variables for the sandbox app, you need to do one more step.

    According to this page http://docs.dotcloud.com/0.9/guides/environment/#adding-environment-variables there are 2 different ways of adding ENV variables.

    1. Using the dotcloud.yml‘s environment section.
    2. Using the dotcloud env cli command

    Whereas dotcloud.yml allows you to define different environment variables for each service, dotcloud env set environment variables for the whole application. Moreover, environment variables set with dotcloud env supersede environment variables defined in dotcloud.yml.

    That means that if we want to have different values for our sandbox app, we just need to run a dotcloud env command to set those variables on the sandbox app, which will override the ones in your dotcloud.yml

    If we just want to change on variable we would run this command.

    $ dotcloud env set NEW_RELIC_APP_NAME='Test Application Name'
    

    If we want to update more then one at a time we would do the following.

    $ dotcloud env set \
    'NEW_RELIC_APP_NAME="Test Application Name"' \
    'NEW_RELIC_LOG_LEVEL=debug'
    

    To make sure that you have your env varibles set correctly you can run the following command.

    $ dotcloud env list
    

    Notes

    • The commands above, are using the new dotCloud 0.9.x CLI, if you are using the older one, you will need to either upgrade to the new one, or refer to the documentation for the old CLI http://docs.dotcloud.com/0.4/guides/environment/
    • When you set your environment variables it will restart your application so that it can install the variables, so to limit your downtime, set all of them in one command.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a django application using mod_python, fairly typical configuration except that media files
I have written an application using Python 2.7 and Tkinter that edits *.docx files.
I have a small GTK python application that imports a package (Twisted) that may
I have a Python application in the bottle web-server that accesses a C shared-object
I have an application that uses Django 1.3 installed in python's site-packages. I want
I have a multi-process python application (processes are spawned by uwsgi) that needs to
I have a web application build in Django + Python that interact with web
I have a Python application in which I would like to monitor the number
I have a python (pygtk) application which starts in different modes depending on arguments.
hi i am working on a django python application using sqlite3 database. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.