Stackato is a private PaaS solution developed by ActiveState. The Python agent can be used in conjunction with Stackato by following the steps outlined below.
The instructions here require you to use version 0.6 or higher of the Stackato VM image. If you use an older version of the Stackato VM image you will need to upgrade.
You would then perform the
update command using the Stackato client.
The PyPM package repository updates daily. If you need to use a newer version of the Python agent than is available from the PyPM package repository, you will instead need to fallback to using pip and source packages from PyPI.
In this case you will need to create in addition to the requirements.txt file used by PyPM, a requirements.pip file as input for pip. In the requirements.pip file you should list the
Agent configuration file
You will need to generate the Python agent configuration on your local system as described in Python agent installation and add that to the directory you push to your Stackato instance.
The option in the agent configuration file for specifying where the agent log file output should go, should be set to:
log_file = stderr
Python agent initialization
Although you can manually include code for initializing the Python agent into the Python module containing your WSGI application entry point, as per instructions for integration with your Python application, a simplified startup method is also available by using the newrelic-admin script.
In the case where you do it manually, such changes would typically be made to the wsgi.py file which includes your Python web application. Since the agent configuration file would be in the same directory, the change to the wsgi.py file would be to add:
import newrelic.agent config_file = os.path.join(os.path.dirname(__file__), 'newrelic.ini') newrelic.agent.initialize(config_file)
Because the directory in the filesystem where the application is installed can change, the location of the agent configuration is calculated relative to the location of the wsgi.py file automatically.
The alternative to adding code to perform initialization of the agent manually is to use the newrelic-admin script.
If you are explicitly defining in the stackato.yml file how to startup your web application by setting the
web entry in the
processes: web: python app.py
You would replace
web so it reads:
processes: web: newrelic-admin run-program python app.py
In other words, you are prefixing the existing command with
At the same time, you should also add an
env section to the stackato.yml file with:
env: NEW_RELIC_CONFIG_FILE: newrelic.ini
If you aren't overriding the
web entry already and instead are relying on the default of the Stackato stack running uWSGI for you the process is a bit different. In this case you will need to add a
web entry to stackato.yml as:
processes: web: newrelic-admin run-program $PROCESSES_WEB
env section is also again required.
PROCESSES_WEB is not defined and this does not work it indicates you are using an older VM image and should upgrade.
Whether the manual or more automated method is used, if necessary for the Python web framework being used, the WSGI application entry point object will also need to be wrapped appropriately.