spawn method

Future<Process> spawn(
  1. List<int> processShards,
  2. int totalShards,
  3. int port
)

Spawns a single Process according to the information in this ProcessManager.

The spawned process will have the following environment variables set in addition to the existing variables:

  • NYXX_SHARDING_SHARD_IDS: The ids of the shards to spawn in the process;
  • NYXX_SHARDING_TOTAL_SHARDS: The total number of shards being spawned across all processes;
  • NYXX_SHARDING_PORT: The port to connect to in order to establish a websocket connection with the manager process.

Implementation

Future<Process> spawn(List<int> processShards, int totalShards, int port) => Process.start(executable, args,
    environment: {
      'NYXX_SHARDING_SHARD_IDS': processShards.join(","),
      'NYXX_SHARDING_TOTAL_SHARDS': totalShards.toString(),
      'NYXX_SHARDING_PORT': port.toString(),
    },
    workingDirectory: cwd);