Rolled out in prod

This commit is contained in:
Lauri Võsandi 2021-04-04 08:58:45 +00:00
parent 0e2f3aef1f
commit bca9264ce9
7 changed files with 25 additions and 15 deletions

3
.env
View File

@ -1,3 +0,0 @@
# MONGO_URI=mongodb://root:salakala@localhost:27017/?replicaSet=kspace-mongo-set
MONGO_URI=mongodb://root:salakala@localhost:27017
DOORBOY_SECRET=doorboy_secret

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

BIN
.overnodebundle Normal file

Binary file not shown.

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# Deploying
```
docker build -t 172.20.40.1:5000/doorboy:latest .
docker push 172.20.40.1:5000/doorboy:latest
overnode pull
overnode up
```

View File

@ -5,14 +5,12 @@ networks:
external: true
services:
doorboy_proxy:
hostname: doorboy.infra.k-space.ee
app:
image: 172.20.40.1:5000/doorboy:latest
hostname: replica${OVERNODE_ID}.doorboy.infra.k-space.ee
restart: unless-stopped
env_file: .env
networks:
infra:
ipv4_address: 172.21.99.97
build:
context: .
ipv4_address: 172.21.57.${OVERNODE_ID}
ipv6_address: 2001:bb8:4008:21:57::${OVERNODE_ID}

View File

@ -9,9 +9,8 @@ import const
app = Sanic(__name__)
#mongodb = MongoClient('mongodb://172.21.27.1,172.21.27.2,172.21.27.3:27017/', replicaSet="kspace-mongo-set").kspace_accounting
mongodb = AsyncIOMotorClient(const.MONGO_URI)
mongodb = mongodb.get_default_database()
db = mongodb.get_default_database()
DOORBOY_SECRET = os.environ["DOORBOY_SECRET"]
@ -22,10 +21,10 @@ async def view_doorboy_uids(request):
if request.headers.get('KEY') != DOORBOY_SECRET:
return text("how about no")
allowed_names = []
async for obj in mongodb.member.find({"enabled": True}):
async for obj in db.member.find({"enabled": True}):
allowed_names.append(obj["_id"])
allowed_uids = []
async for obj in mongodb.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner_id": {"$exists":True}, "token.enabled": True}, {"inventory.owner_id": True, "token.uid_hash": True }):
async for obj in db.inventory.find({"token.uid_hash": {"$exists":True}, "inventory.owner_id": {"$exists":True}, "token.enabled": True}, {"inventory.owner_id": True, "token.uid_hash": True }):
if obj["inventory"].pop("owner_id") in allowed_names:
del obj["_id"]
del obj["inventory"]
@ -50,7 +49,7 @@ async def view_longpoll(request):
}
]
try:
async with mongodb.eventlog.watch(pipeline) as stream:
async with db.eventlog.watch(pipeline) as stream:
await response.write("data: watch-stream-opened\n\n")
async for event in stream:
if event["fullDocument"].get("type") == "open-door":

6
overnode.yml Normal file
View File

@ -0,0 +1,6 @@
id: doorboy
version: 3.7
app:
docker-compose.yml: 1, 2, 3