annotate service/xidle/tasks.py @ 1748:d012c53c5ae8

powereagle now registers a hostname with dhcp so we don't have to hunt for it
author drewp@bigasterisk.com
date Sat, 23 Mar 2024 14:57:59 -0700
parents 2500a3ee9102
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
772
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
1 from invoke import task, Collection
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
2 import sys
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
3 sys.path.append('/my/proj/release')
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
4 from serv_tasks import serv_tasks
690
3df357924f1d xidle rewrite for docker, py3
drewp@bigasterisk.com
parents: 457
diff changeset
5
772
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
6 ns = Collection()
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
7 serv_tasks(ns, 'serv.n3', 'xidle_dash')
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
8
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
9 if 0:
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
10
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
11 TAG_x86 = f'bang6:5000/{JOB.lower()}_x86:latest'
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
12 TAG_pi = f'bang6:5000/{JOB.lower()}_pi:latest'
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
13 ANSIBLE_TAG = 'homeauto_xidle'
362
cd95bd418d78 xidle to docker
drewp@bigasterisk.com
parents:
diff changeset
14
772
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
15 @task
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
16 def build_image_x86(ctx):
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
17 ctx.run(f'docker build --network=host -t {TAG_x86} .')
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
18 @task
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
19 def build_image_pi(ctx):
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
20 ctx.run(f'docker build --file Dockerfile.pi --network=host -t {TAG_pi} .')
362
cd95bd418d78 xidle to docker
drewp@bigasterisk.com
parents:
diff changeset
21
772
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
22 @task(pre=[build_image_x86])
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
23 def push_image_x86(ctx):
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
24 ctx.run(f'docker push {TAG_x86}')
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
25 @task(pre=[build_image_pi])
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
26 def push_image_pi(ctx):
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
27 ctx.run(f'docker push {TAG_pi}')
362
cd95bd418d78 xidle to docker
drewp@bigasterisk.com
parents:
diff changeset
28
772
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
29 @task(pre=[build_image_x86])
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
30 def shell(ctx):
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
31 ctx.run(f'docker run --rm -it --cap-add SYS_PTRACE -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /home/drewp/.Xauthority:/root/.Xauthority --net=host {TAG_x86} /bin/bash', pty=True)
457
d96621e2fc08 add redeploy
drewp@bigasterisk.com
parents: 362
diff changeset
32
772
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
33 @task(pre=[build_image_x86])
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
34 def local_run(ctx):
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
35 ctx.run(f'docker run --rm -it -v /tmp/.X11-unix/:/tmp/.X11-unix/ -v /home/drewp/.Xauthority:/root/.Xauthority -p {PORT}:{PORT} -v /etc/resolv.conf:/etc/resolv.conf --net=host {TAG_x86} python3 xidle.py -v', pty=True)
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
36
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
37 @task(pre=[push_image_x86, push_image_pi])
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
38 def redeploy(ctx):
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
39 ctx.run(f'sudo /my/proj/ansible/playbook -t {ANSIBLE_TAG}')
2500a3ee9102 xidle build
drewp@bigasterisk.com
parents: 690
diff changeset
40 #ctx.run(f'supervisorctl -s http://bang:9001/ restart {JOB}_{PORT}')