2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 11:18:27 +08:00
artiq/frontend/artiqd

41 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env python3
import asyncio
2014-10-25 11:34:52 +08:00
import argparse
from artiq.management.pc_rpc import Server
from artiq.management.scheduler import Scheduler
2014-10-25 11:34:52 +08:00
def _get_args():
parser = argparse.ArgumentParser(description="PDQ2 controller")
parser.add_argument(
"--bind", default="::1",
help="hostname or IP address to bind to")
parser.add_argument(
"--port", default=8888, type=int,
help="TCP port to listen to")
return parser.parse_args()
def main():
2014-10-25 11:34:52 +08:00
args = _get_args()
loop = asyncio.get_event_loop()
try:
2014-10-23 18:48:03 +08:00
scheduler = Scheduler()
loop.run_until_complete(scheduler.start())
try:
server = Server(scheduler)
2014-10-25 11:34:52 +08:00
loop.run_until_complete(server.start(args.bind, args.port))
2014-10-23 18:48:03 +08:00
try:
loop.run_forever()
2014-10-23 18:48:03 +08:00
finally:
loop.run_until_complete(server.stop())
finally:
loop.run_until_complete(scheduler.stop())
finally:
loop.close()
if __name__ == "__main__":
main()