annotate service/collector/tasks.py @ 1458:be5fc8791c4d

dep on influxdb Ignore-this: a89f9f27d849d29e6b11234d6556c0b1 darcs-hash:797ee4baafebe0a5bd13d29d715c5869a091afdb
author drewp <drewp@bigasterisk.com>
date Wed, 25 Sep 2019 17:56:15 -0700
parents 420effc5e138
children 732e30c509d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1448
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
1 from invoke import task
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
2 JOB = 'collector'
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
3 PORT = 9072
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
4 TAG_x86 = f'bang6:5000/{JOB.lower()}_x86:latest'
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
5
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
6 ANSIBLE_TAG = 'reasoning' # sic
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
7
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
8 @task
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
9 def build_image(ctx):
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
10 ctx.run(f'docker build --network=host -t {TAG_x86} .')
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
11
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
12 @task(pre=[build_image])
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
13 def push_image(ctx):
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
14 ctx.run(f'docker push {TAG_x86}')
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
15
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
16 @task(pre=[build_image])
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
17 def shell(ctx):
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
18 ctx.run(f'docker run --rm --name={JOB}_shell --cap-add SYS_PTRACE --dns 10.2.0.1 --dns-search bigasterisk.com -it --cap-add SYS_PTRACE -v `pwd`/.mypy_cache:/opt/.mypy_cache -v `pwd`/../../stubs:/opt/stubs -v `pwd`/sse_collector.py:/opt/sse_collector.py --net=host {TAG_x86} /bin/bash', pty=True)
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
19
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
20 @task(pre=[build_image])
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
21 def local_run(ctx):
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
22 ctx.run(f'docker run --rm -it -p {PORT}:{PORT} --net=host --cap-add SYS_PTRACE --dns 10.2.0.1 --dns-search bigasterisk.com -v `pwd`/static:/opt/static {TAG_x86} python3 sse_collector.py -v', pty=True)
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
23
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
24 #local_run_strace: build_image
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
25 # docker run --rm -it -p ${PORT}:${PORT} \ --name=$(JOB)_local \ --net=host \ --cap-add SYS_PTRACE \ ${TAG} \ strace -f -tts 200 python3 /mnt/sse_collector.py -v
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
26
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
27 #local_run_pyspy: build_image
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
28 # docker run --rm -it -p ${PORT}:${PORT} \ --name=$(JOB)_local \ --net=host \ --cap-add SYS_PTRACE \ ${TAG} \ py-spy -- python3 sse_collector.py
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
29
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
30 #typecheck: build_image
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
31 # docker run --rm -it -p ${PORT}:${PORT} \ --name=$(JOB)_mypy \ --net=host \ -v `pwd`/.mypy_cache:/opt/.mypy_cache \ ${TAG} \
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
32 # /usr/local/bin/mypy -m sse_collector -m export_to_influxdb -m logsetup -m patchablegraph -m patchsource -m rdfdb.patch
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
33
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
34 #redeploy: push_image
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
35 # supervisorctl restart sse_collector_9072
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
36
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
37 @task(pre=[push_image])
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
38 def redeploy(ctx):
420effc5e138 makefile to invoke
drewp <drewp@bigasterisk.com>
parents:
diff changeset
39 ctx.run(f'supervisorctl -s http://bang:9001/ restart sse_{JOB}_{PORT}')