Beispiel #1
0
        rec2db.stop()
        raise Exception("VA exited. This should not happen.")

    except:
        print(traceback.format_exc(), flush=True)
    print("connect stopped", flush=True)

def quit_service(signum, sigframe):
    stop.set()

signal(SIGTERM, quit_service)
dba=DBIngest(host=dbhost, index="algorithms", office=office)
dbs=DBQuery(host=dbhost, index="sensors", office=office)

# register algorithm (while waiting for db to startup)
dba.wait(stop)
algorithm=dba.ingest({
    "name": text["crowd-counting"],
    "office": {
        "lat": office[0],
        "lon": office[1],
    },
    "status": "processing",
    "skip": every_nth_frame,
})["_id"]

# compete for a sensor connection
while not stop.is_set():
    try:
        print("Searching...", flush=True)
        for sensor in dbs.search("type:'camera' and status:'idle' and algorithm='crowd-counting' and office:["+str(office[0])+","+str(office[1])+"] and url:*"):
Beispiel #2
0
office = list(map(float, env["OFFICE"].split(",")))
dbhost = env["DBHOST"]

stop = Event()


def quit_service(signum, sigframe):
    stop.set()


signal(SIGTERM, quit_service)

# register trigger
dbt = DBIngest(index="services", office=office, host=dbhost)
dbt.wait(stop)
rt = dbt.ingest({
    "name": text["alert trigger"],
    "service": text["triggers"],
    "status": "active",
})

imbalance = ImbalanceTrigger()
occupency = OccupencyTrigger()
cpu = CPUTrigger()
with ThreadPoolExecutor(3) as e:
    e.submit(imbalance.loop, stop)
    e.submit(occupency.loop, stop)
    e.submit(cpu.loop, stop)

dbt.delete(rt["_id"])
Beispiel #3
0
    float, os.environ["OFFICE"].split(","))) if "OFFICE" in os.environ else "*"
dbhost = os.environ["DBHOST"]
storage = "/var/www/mp4"

stop = Event()


def quit_service(signum, sigframe):
    stop.set()


signal(SIGTERM, quit_service)
dbs = DBIngest(index="services", office=office, host=dbhost)
rs = None
if isinstance(office, list):
    dbs.wait(stop)
    rs = dbs.ingest({
        "name": text["cleanup"],
        "service": text["maintenance"],
        "status": "active",
    })

while not stop.is_set():
    print("Searching...", flush=True)
    for index in indexes:
        if stop.is_set(): break

        db = DBQuery(index=index, office=office, host=dbhost)
        try:
            for r in db.search("time<now-" + str(retention_time * 1000),
                               size=500):