diff --git a/calparrot/stop.py b/calparrot/stop.py new file mode 100644 index 0000000000000000000000000000000000000000..568314783c73e4b29cf6442caca17966612d80fa --- /dev/null +++ b/calparrot/stop.py @@ -0,0 +1,20 @@ +import argparse +import logging +import sys + +from tornado.httpclient import HTTPClient + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument('port', type=int, help="Port number of CalParrot server") + args = ap.parse_args() + logging.basicConfig(level=logging.INFO) + + client = HTTPClient() + client.fetch(f"http://127.0.0.1:{args.port}/.calparrot/stop", method='POST', + allow_nonstandard_methods=True) # POST with no body + logging.info("Asked CalParrot server to shut down") + + +if __name__ == '__main__': + sys.exit(main())