Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Relic Solution: Using the Python agent with Celery’s generic bash init script

level-up
relic-solutions

#1

Learn how to use the Python agent with Celery’s generic bash init script (below)!!!


Using the Python agent with Celery’s generic bash init script
#2

The Python agent instruments Celery via our normal integration process, however Celery also includes an init script that allows users to easily run Celery from the command line.

Our Wrapper Script goes around the celery command itself, however with the Celery init scripts, you are running a script that is in turn running the celery command. This means that you will need to make sure to add our Wrapper Script around the celery command that is called inside the init script.

The way you would run our agent with Celery outside of a bash script is with our Wrapper Script command, which might look like:

NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini newrelic-admin run-program celery YOUR_ORIGINAL_COMMAND_OPTIONS

To translate that into the init script, you need to wrap the celery command itself, which is located in the following line of the script:

CELERY_BIN=${CELERY_BIN:-"celery"}

To add the agent’s Wrapper Script, you might change the CELERY_BIN variable to the following where some/path/ is substituted for your actual path to the file or package:

CELERY_BIN=${CELERY_BIN:-"NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini /some/path/bin/newrelic-admin run-python /some/path/bin/celery"}

With this change, every time CELERY_BIN is called, it will be called with our Wrapper Script around the actual celery command.

Give it a try!