Beispiel #1
0
def shutdown_datastore():
  """ Top level function for bringing down Cassandra.

  Returns:
    True on success, False otherwise.
  """
  logging.info("Shutting down Cassandra.")
  monit_interface.stop(
    cassandra_interface.CASSANDRA_MONIT_WATCH_NAME, is_group=False)
  logging.warning("Done!")
  return True
Beispiel #2
0
def shutdown_datastore():
    """ Top level function for bringing down Cassandra.

  Returns:
    True on success, False otherwise.
  """
    logger.info("Shutting down Cassandra.")
    monit_interface.stop(cassandra_interface.CASSANDRA_MONIT_WATCH_NAME,
                         is_group=False)
    logger.warning("Done!")
    return True
    def test_stop(self):
        testing.disable_logging()

        flexmock(subprocess)\
          .should_receive('call')\
          .and_return(0)
        self.assertEqual(True, monit_interface.stop("watch_name"))

        flexmock(subprocess)\
          .should_receive('call')\
          .and_return(1)
        self.assertEqual(False, monit_interface.stop("watch_name"))
Beispiel #4
0
def stop_app_instance(app_name, port):
    """ Stops a Google App Engine application process instance on current
      machine.

  Args:
    app_name: A string, the name of application to stop.
    port: The port the application is running on.
  Returns:
    True on success, False otherwise.
  """
    if not misc.is_app_name_valid(app_name):
        logging.error("Unable to kill app process %s on port %d because of " \
          "invalid name for application" % (app_name, int(port)))
        return False

    logging.info("Stopping application %s" % app_name)
    watch = "app___" + app_name + "-" + str(port)
    if not monit_interface.stop(watch, is_group=False):
        logging.error("Unable to stop application server for app {0} on " \
          "port {1}".format(app_name, port))
        return False

    # Now that the AppServer is stopped, remove its monit config file so that
    # monit doesn't pick it up and restart it.
    monit_config_file = '{}/appscale-{}.cfg'.format(MONIT_CONFIG_DIR, watch)
    try:
        os.remove(monit_config_file)
    except OSError as os_error:
        logging.error("Error deleting {0}".format(monit_config_file))

    return True
def stop_service(service_name):
  logging.info("Stopping " + service_name)
  if not monit_interface.stop(service_name):
    logging.error("Monit was unable to stop " + service_name)
    return 1
  else:
    logging.info("Successfully stopped " + service_name)
    return 0
Beispiel #6
0
def stop_service(service_name):
    logging.info("Stopping " + service_name)
    if not monit_interface.stop(service_name):
        logging.error("Monit was unable to stop " + service_name)
        return 1
    else:
        logging.info("Successfully stopped " + service_name)
        return 0
Beispiel #7
0
def stop_app(app_name):
    """ Stops all process instances of a Google App Engine application on this
      machine.

  Args:
    app_name: Name of application to stop
  Returns:
    True on success, False otherwise
  """
    if not misc.is_app_name_valid(app_name):
        logging.error("Unable to kill app process %s on because of " \
          "invalid name for application" % (app_name))
        return False

    logging.info("Stopping application %s" % app_name)
    watch = "app___" + app_name
    monit_result = monit_interface.stop(watch)

    if not monit_result:
        logging.error("Unable to shut down monit interface for watch %s" %
                      watch)
        return False

    # Remove the monit config files for the application.
    # TODO: Reload monit to pick up config changes.
    config_files = glob.glob('{}/appscale-{}-*.cfg'.format(
        MONIT_CONFIG_DIR, watch))
    for config_file in config_files:
        try:
            os.remove(config_file)
        except OSError:
            logging.exception('Error removing {}'.format(config_file))

    if not remove_logrotate(app_name):
        logging.error(
            "Error while setting up log rotation for application: {}".format(
                app_name))

    return True