(* Configuration for the server. This is a sample config for a single
   host. See the embedded comments what to change for several hosts
 *)

netplex {
  controller {
    max_level = "debug";    (* Log level *)
    logging {
      type = "stderr";    (* Log to stderr *)
    }
  };

  (* Now we describe the controller/multiplier service. The two RPC programs
     Controller and Multiplier run in the same process, and can be reached
     over the same port. The only difference is that Multiplier is the
     external interface while Controller is internally used.

     This service must only run once in the cluster.
  *)

  service {
    name = "mm_controller";
    protocol {
      (* This section creates the socket *)
      name = "mm_controller/rpc";
      address {
        type = "internet";
        bind = "0.0.0.0:2021";
      };
    };
    processor {
      type = "mm_controller";
      (* All workers have to be listed here. If a worker is supposed to run
         several times on a host, list the port several times.
      *)
      worker { host = "localhost"; port = 2022 };
      worker { host = "localhost"; port = 2022 };
    };
    workload_manager {
      (* This means there is only one process for the controller: *)
      type = "constant";
      jobs = 1
    };
  };


  (* The worker service. For every incoming TCP connection we want to start
     a new process, so we use a "dynamic" workload manager.

     In a cluster setup, the worker can run alone on hosts. To achieve
     this, just omit the service section for the controller in this 
     config file so that there is only the following worker service.
   *)

  service {
    name = "mm_worker";
    protocol {
      (* This section creates the socket *)
      name = "mm_worker/rpc";
      address {
        type = "internet";
        bind = "0.0.0.0:2022";
      };
    };
    processor {
      type = "mm_worker";
      controller_host = "localhost";
      controller_port = 2021;
    };
    workload_manager {
      (* Allow up to 20 processes of this kind: *)
      type = "dynamic";
      max_jobs_per_thread = 1;
      min_free_jobs_capacity = 1;
      max_free_jobs_capacity = 1;
      max_threads = 20;
    };
  };
}
