def start(config_loc, watch): """ Starts a watch on god given a configuration file. Deletes the configuration after it is used. Args: config_loc: The location of the god configuration file watch: Name of the watch being started Returns: True on success, False otherwise """ if not misc.is_string_secure(config_loc): logging.error("Configuration file location str (%s) is a possible security violation"%config_loc) return False if not misc.is_string_secure(watch): logging.error("Watch string (%s) is a possible security violation"%watch) return False return_status = subprocess.call(['god', 'load', config_loc]) if return_status != 0: logging.error("God load command returned with status %d when setting up watch %s"%(int(return_status), str(watch))) return False return_status = subprocess.call(['god', 'start', watch]) if return_status != 0: logging.error("God load command returned with status %d when setting up watch %s"%(return_status, watch)) return False logging.info("Starting watch %s"%str(watch)) file_io.delete(config_loc) return True
def stop_app_instance(app_name, port): """ Stops a Google App Engine application process instance on current machine. Args: app_name: 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) god_result = god_interface.stop(watch) # hack: God fails to shutdown processes so we do it via a system command # TODO: fix it or find an alternative to god pid_file = constants.APP_PID_DIR + app_name + '-' + port pid = file_io.read(pid_file) if str(port).isdigit(): if subprocess.call(['kill', '-9', pid]) != 0: logging.error("Unable to kill app process %s on port %d with pid %s"%\ (app_name, int(port), str(pid))) file_io.delete(pid_file) return god_result
def remove_config_files(app_id): """ Removed celery worker and config files. Args: app_id: The application identifer. """ worker_file = TaskQueueConfig.get_celery_worker_script_path(app_id) config_file = TaskQueueConfig.get_celery_configuration_path(app_id) file_io.delete(worker_file) file_io.delete(config_file)
def start(config_loc, watch): """ Starts a watch on god given a configuration file. Deletes the configuration after it is used. Args: config_loc: The location of the god configuration file watch: Name of the watch being started Returns: True on success, False otherwise """ if not misc.is_string_secure(config_loc): logging.error( "Configuration file location str (%s) is a possible security violation" % config_loc) return False if not misc.is_string_secure(watch): logging.error("Watch string (%s) is a possible security violation" % watch) return False return_status = subprocess.call(['god', 'load', config_loc]) if return_status != 0: logging.error( "God load command returned with status %d when setting up watch %s" % (int(return_status), str(watch))) return False return_status = subprocess.call(['god', 'start', watch]) if return_status != 0: logging.error( "God load command returned with status %d when setting up watch %s" % (return_status, watch)) return False logging.info("Starting watch %s" % str(watch)) file_io.delete(config_loc) return True