fix
This commit is contained in:
0
app/daemons/__init__.py
Normal file
0
app/daemons/__init__.py
Normal file
20
app/daemons/api.py
Normal file
20
app/daemons/api.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import fastapi
|
||||
import uvicorn
|
||||
|
||||
from app.routers import acquire
|
||||
from app.routers import release
|
||||
|
||||
from app.storage import mongo
|
||||
from daemons import base
|
||||
|
||||
|
||||
class Daemon(base.Daemon):
|
||||
def execute(self):
|
||||
app = fastapi.FastAPI()
|
||||
|
||||
app.include_router(acquire.router)
|
||||
app.include_router(release.router)
|
||||
|
||||
mongo.create_indexes()
|
||||
|
||||
uvicorn.run(app, host="0.0.0.0", port=80)
|
||||
3
app/daemons/base.py
Normal file
3
app/daemons/base.py
Normal file
@@ -0,0 +1,3 @@
|
||||
class Daemon:
|
||||
def execute(self):
|
||||
raise NotImplementedError
|
||||
11
app/daemons/cleaner.py
Normal file
11
app/daemons/cleaner.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from app.daemons import base
|
||||
from app.storage.mongo import locks
|
||||
import time
|
||||
from app.utils import time as time_utils
|
||||
|
||||
|
||||
class Daemon(base.Daemon):
|
||||
def execute(self):
|
||||
while True:
|
||||
locks.collection.delete_many({'locked_until': {'$lt': time_utils.now()}})
|
||||
time.sleep(5)
|
||||
Reference in New Issue
Block a user