Skip to content

Commit 1a3cac6

Browse files
committed
Merge branch 'feature/newrelic' into develop
Closes #408 [ENG-9934]
2 parents 9963baf + 551aeb3 commit 1a3cac6

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ celery = "5.5.0"
4949
black = "^25.1.0"
5050
isort = "^6.0.1"
5151
ruff = "^0.12.7"
52+
newrelic = "10.8.1"
5253

5354

5455
[tool.poetry.group.dev]

tasks.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23

34
from invoke import task
45

@@ -70,3 +71,28 @@ def celery(ctx, loglevel='INFO', hostname='%h', concurrency=None):
7071
if concurrency:
7172
command.extend(['--concurrency', concurrency])
7273
app.worker_main(command)
74+
75+
76+
@task
77+
def newrelic_init(ctx, key=None, verbose=False):
78+
if key is None:
79+
sys.exit('No newrelic api key given. Please generate one and rerun this command '
80+
'with `invoke newrelic-init --key=$key`')
81+
82+
cmd_tmpl = 'newrelic-admin generate-config {} newrelic.ini'
83+
cmd = cmd_tmpl.format(key)
84+
if verbose:
85+
print(cmd_tmpl.format('<redacted>'))
86+
ctx.run(cmd, pty=True)
87+
88+
89+
@task
90+
def newrelic_server(ctx, config='newrelic.ini', verbose=False):
91+
if not os.path.exists(config):
92+
sys.exit("Couldn't find config file '{}'. Check path or run `invoke newrelic_init` "
93+
"to generate it.".format(config))
94+
95+
cmd = f'poetry run env NEW_RELIC_CONFIG_FILE={config} newrelic-admin run-program invoke server'
96+
if verbose:
97+
print(cmd)
98+
ctx.run(cmd, pty=True)

0 commit comments

Comments
 (0)