Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ celery = "5.5.0"
black = "^25.1.0"
isort = "^6.0.1"
ruff = "^0.12.7"
newrelic = "10.8.1"


[tool.poetry.group.dev]
Expand Down
26 changes: 26 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys

from invoke import task

Expand Down Expand Up @@ -70,3 +71,28 @@ def celery(ctx, loglevel='INFO', hostname='%h', concurrency=None):
if concurrency:
command.extend(['--concurrency', concurrency])
app.worker_main(command)


@task
def newrelic_init(ctx, key=None, verbose=False):
if key is None:
sys.exit('No newrelic api key given. Please generate one and rerun this command '
'with `invoke newrelic_init --key=$key`')

cmd_tmpl = 'newrelic-admin generate-config {} newrelic.ini'
cmd = cmd_tmpl.format(key)
if verbose:
print(cmd_tmpl.format('<redacted>'))
ctx.run(cmd, pty=True)


@task
def newrelic_server(ctx, config='newrelic.ini', verbose=False):
if not os.path.exists(config):
sys.exit("Couldn't find config file '{}'. Check path or run `invoke newrelic_init` "
"to generate it.".format(config))

cmd = f'poetry run env NEW_RELIC_CONFIG_FILE={config} newrelic-admin run-program invoke server'
if verbose:
print(cmd)
ctx.run(cmd, pty=True)