def start_worker(self, json_request):
    """ Starts taskqueue workers if they are not already running.
        A worker can be started on both a master and slave node.
 
    Args:
      json_request: A JSON string with the application id.
    Returns:
      A JSON string with the error status and error reason.
    """
    request = self.__parse_json_and_validate_tags(json_request,  
                                         self.SETUP_WORKERS_TAGS)
    logging.info("Start worker request: {0}".format(request))
    if request in 'error':
      return json.dumps(request)

    app_id = self.__cleanse(request['app_id'])

    config = TaskQueueConfig(TaskQueueConfig.RABBITMQ, app_id)

    # Load the queue info.
    try:
      self.__queue_info_cache[app_id] = config.load_queues_from_file(app_id)
      config.create_celery_file(TaskQueueConfig.QUEUE_INFO_FILE) 
      config.create_celery_worker_scripts(TaskQueueConfig.QUEUE_INFO_FILE)
    except ValueError, value_error:
      return json.dumps({"error": True, "reason": str(value_error)}) 
    except NameError, name_error:
      return json.dumps({"error": True, "reason": str(name_error)}) 
    except Exception, exception:
      logging.error("******Unknown exception******")
      logging.exception(exception)
      return json.dumps({"error": True, "reason": str(exception)}) 
   
    log_file = self.LOG_DIR + app_id + ".log"
    command = ["/usr/local/bin/celery",
               "worker",
               "--app=" + \
                    TaskQueueConfig.get_celery_worker_module_name(app_id),
               #"--autoscale=" + self.MIN_MAX_CONCURRENCY,
               "--hostname=%h." + app_id,
               "--workdir=" + TaskQueueConfig.CELERY_WORKER_DIR,
               "--logfile=" + log_file,
               "--time-limit=" + str(self.HARD_TIME_LIMIT),
               "--concurrency=" + str(TaskQueueConfig.CELERY_CONCURRENCY),
               "--soft-time-limit=" + str(self.TASK_SOFT_TIME_LIMIT),
               "--pidfile=" + self.PID_FILE_LOC + 'celery___' + \
                             app_id + ".pid",
               "--statedb=" + TaskQueueConfig.CELERY_STATE_DIR + 'worker___' + \
                             app_id + ".db",
               "--autoreload -Ofair"]
    start_command = str(' '.join(command))
    stop_command = self.get_worker_stop_command(app_id)
    watch = "celery-" + str(app_id)
    monit_app_configuration.create_config_file(watch,
                                               start_command, 
                                               stop_command, 
                                               [self.CELERY_PORT],
                                               env_vars=self.CELERY_ENV_VARS)
    if monit_interface.start(watch):
      json_response = {'error': False}
    else:
      json_response = {'error': True, 
                       'reason': "Start of monit watch for %s failed" % watch}
    return json.dumps(json_response)
dataset/ETHPy150Open AppScale/appscale/AppTaskQueue/distributed_tq.py/DistributedTaskQueue.start_worker/swapped operands of `in`