diff --git a/src/dlstbx/cli/shutdown.py b/src/dlstbx/cli/shutdown.py index e9e977b39..4a4beb1f2 100644 --- a/src/dlstbx/cli/shutdown.py +++ b/src/dlstbx/cli/shutdown.py @@ -1,84 +1,6 @@ -# -# dlstbx.shutdown -# Stop a dlstbx service -# - - -import sys -from optparse import SUPPRESS_HELP, OptionParser - -import workflows -import workflows.services -from workflows.transport.stomp_transport import StompTransport - -# Example: dlstbx.shutdown computer.12345 -# dlstbx.shutdown --all +import zocalo.cli.shutdown def run(): - parser = OptionParser() - - parser.add_option("-?", action="help", help=SUPPRESS_HELP) - # parser.add_option("--all", dest="all", - # action="store_true", default=False, - # help="Stop all dlstbx services (use with caution)") - - known_services = workflows.services.get_known_services() - parser.add_option( - "-s", - "--service", - dest="services", - metavar="SVC", - action="append", - default=[], - help="Stop all instances of a service. Use 'none' for instances without " - "loaded service. Known services: " + ", ".join(known_services), - ) - parser.add_option( - "--test", - action="store_true", - dest="test", - help="Run in ActiveMQ testing namespace (zocdev, default)", - ) - parser.add_option( - "--live", - action="store_true", - dest="test", - help="Run in ActiveMQ live namespace (zocalo)", - ) - - # change settings when in live mode - default_configuration = "/dls_sw/apps/zocalo/secrets/credentials-testing.cfg" - if "--live" in sys.argv: - default_configuration = "/dls_sw/apps/zocalo/secrets/credentials-live.cfg" - - StompTransport.load_configuration_file(default_configuration) - StompTransport.add_command_line_options(parser) - (options, args) = parser.parse_args(sys.argv[1:]) - stomp = StompTransport() - - if not options.services and not len(args): - print("Need to specify one or more services to shut down.") - print("Either specify service groups with -s or specify specific instances") - print("as: hostname.pid") - sys.exit(1) - - stomp.connect() - - for host in args: - if not host.startswith("uk.ac.diamond."): - host = "uk.ac.diamond." + host - - message = {"command": "shutdown", "host": host} - - stomp.broadcast("command", message) - print("Shutting down", host) - - for service in options.services: - if service.lower() == "none": - # Special case for placeholder instances - service = None - message = {"command": "shutdown", "service": service} - - stomp.broadcast("command", message) - print("Stopping all instances of", service) + print("\ndlstbx.shutdown is deprecated. Use 'zocalo.shutdown' instead\n") + zocalo.cli.shutdown.run()