annotate service/arduinoNode/tasks.py @ 1745:d90cb7c06f15

try to crash if mqtt doesn't connect
author drewp@bigasterisk.com
date Thu, 09 Nov 2023 17:21:59 -0800
parents a93fbf0d0daa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
620
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
1 from invoke import task
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
2
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
3 JOB = 'arduinoNode'
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
4 PORT = 9059
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
5 TAG = f'bang6:5000/{JOB.lower()}:latest'
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
6 ANSIBLE_TAG = JOB
336
5a0dd334023e docker and makefile for arduinoNode
drewp@bigasterisk.com
parents:
diff changeset
7
620
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
8 @task
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
9 def build_image(ctx):
722
a93fbf0d0daa dep updates; graph url renames; and other build updates
drewp@bigasterisk.com
parents: 623
diff changeset
10 ctx.run(f'docker build --network=host -t {TAG} .')
620
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
11
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
12 @task(pre=[build_image])
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
13 def push_image(ctx):
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
14 ctx.run(f'docker push {TAG}')
336
5a0dd334023e docker and makefile for arduinoNode
drewp@bigasterisk.com
parents:
diff changeset
15
620
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
16 @task(pre=[build_image])
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
17 def shell(ctx):
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
18 ctx.run(f'docker run --name={JOB}_shell --rm -it --cap-add SYS_PTRACE --net=host --device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900cepU-if00-port0 -v `pwd`/config:/opt/config {TAG} /bin/bash', pty=True)
343
13b2a61650c1 fix pushconfig
drewp@bigasterisk.com
parents: 336
diff changeset
19
620
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
20 @task(pre=[build_image])
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
21 def local_run(ctx):
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
22 ctx.run(f'docker run --name={JOB}_local --rm -it -p 9059:9059 --device=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A900cepU-if00-port0 --net=host --dns 10.2.0.1 --dns-search bigasterisk.com {TAG} python ./arduinoNode.py -v', pty=True)
456
12f9f1838fb5 arduinoNode: build updates, stats support, etc
drewp@bigasterisk.com
parents: 383
diff changeset
23
620
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
24 @task
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
25 def push_config(ctx):
623
048a8df60e2e fix pushconfig host lookup
drewp@bigasterisk.com
parents: 621
diff changeset
26 ctx.run(f'docker run --rm --net=host --dns 10.2.0.1 --dns-search bigasterisk.com -v `pwd`/config:/opt/config bang6:5000/arduino_node python pushConfig.py arduino/')
456
12f9f1838fb5 arduinoNode: build updates, stats support, etc
drewp@bigasterisk.com
parents: 383
diff changeset
27
620
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
28 @task(pre=[push_image])
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
29 def redeploy(ctx):
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
30 ctx.run(f'sudo /my/proj/ansible/playbook -l bang -t {ANSIBLE_TAG}')
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
31
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
32 @task
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
33 def lightsout(ctx):
5c750342604d arduinonode to docker
drewp@bigasterisk.com
parents: 456
diff changeset
34 ctx.run(rf'curl http://bang:9059/output\?s\=http://projects.bigasterisk.com/room/speakersStrips\&p\=http://projects.bigasterisk.com/room/x -XPUT -v -d 199')
621
686079900c20 arduinonode: per-device-type timing stats
drewp@bigasterisk.com
parents: 620
diff changeset
35
686079900c20 arduinonode: per-device-type timing stats
drewp@bigasterisk.com
parents: 620
diff changeset
36 @task
686079900c20 arduinonode: per-device-type timing stats
drewp@bigasterisk.com
parents: 620
diff changeset
37 def lightstest(ctx):
686079900c20 arduinonode: per-device-type timing stats
drewp@bigasterisk.com
parents: 620
diff changeset
38 ctx.run(rf'curl http://bang:9059/output\?s\=http://projects.bigasterisk.com/room/speakersStrips\&p\=http://projects.bigasterisk.com/room/x -XPUT -v -d 100; sleep 3; curl http://bang:9059/output\?s\=http://projects.bigasterisk.com/room/speakersStrips\&p\=http://projects.bigasterisk.com/room/x -XPUT -v -d 199')