def at_sync_call_async(): return serverboards.run_async(at_async_world)
async def init(*args, **kwargs): serverboards.run_async(real_init, result=False) return 30 * 60 # call init every 30min, just in case it went down
exported_ = await exported() assert exported_ == "exported" print("exported ok", file=sys.stderr) exported_ = await exported_with_back_call() assert exported_ == "exported w bc" print("exported ok", file=sys.stderr) try: await exported_with_exception() assert False, "Should have excepted" except Exception as e: print(e, file=sys.stderr) except Exception as e: print("Exception", e, file=sys.stderr) serverboards.log_traceback(e) ok = False sys.exit(1) finally: print("Exit!", ok, file=sys.stderr) sys.exit(0 if ok else 1) if __name__ == '__main__': serverboards.run_async(test) serverboards.set_debug() serverboards.loop(with_monitor=True) sys.exit(0 if ok else 1)
def main(): serverboards.run_async(update_settings, result=False) serverboards.loop()
async def test(): printc("Testing") await init() await curio.sleep(3) printc("Remove service A", color="green") await remove_service({"uuid": "A"}) await curio.sleep(3) printc("Add again service A", color="green") await inserted_service({ "uuid": "A", "type": "http", "tags": ["status:ok"], "name": "Service A" }) await curio.sleep(3) sys.exit(0) if __name__ == '__main__': serverboards.run_async(subscribe_to_services, result=False) if len(sys.argv) > 1 and sys.argv[1] == 'test': import yaml printc("test mode") data = yaml.load(open("mock.yaml")) serverboards.test_mode(test, mock_data=data) sys.exit(1) # serverboards.set_debug("/tmp/serviceup.log") serverboards.loop()