Mercurial > code > home > repos > homeauto
annotate service/reasoning/tasks.py @ 1374:ac127fdace62
build/import update for reasoning service
Ignore-this: 5e2a8d717e7273bf4a84dd467cccab17
darcs-hash:dc2e5f5c0ee7beb2d72f2c585d88480c5a1312df
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 06 May 2019 00:05:24 -0700 |
parents | |
children | 6c86c6a87eab |
rev | line source |
---|---|
1374
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
1 from invoke import task |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
2 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
3 JOB='reasoning' |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
4 PORT=9071 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
5 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
6 TAG=f'bang6:5000/{JOB}_x86:latest' |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
7 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
8 @task |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
9 def build_image(ctx): |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
10 ctx.run(f'docker build --network=host -t {TAG} .') |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
11 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 @task(pre=[build_image]) |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
13 def push_image(ctx): |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
14 ctx.run(f'docker push {TAG}') |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
15 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
16 @task |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
17 def shell(ctx): |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 ctx.run(f'docker run --rm -it --cap-add SYS_PTRACE --net=host {TAG} /bin/bash') |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
19 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
20 @task(pre=[build_image]) |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
21 def local_run(ctx): |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
22 ctx.run(f'docker run --rm -it -p {PORT}:{PORT} -v `pwd`:/mnt --net=host {TAG} python /mnt/{JOB}.py -iro', pty=True) |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
23 |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
24 @task(pre=[build_image]) |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
25 def redeploy(ctx): |
ac127fdace62
build/import update for reasoning service
drewp <drewp@bigasterisk.com>
parents:
diff
changeset
|
26 ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}') |