fix(gateway): make NOMAD_ALLOC_INDEX environment variable optional

This commit is contained in:
spiral 2022-04-19 16:17:10 -04:00
parent 6faed635fa
commit a5af6793f8
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -81,7 +81,7 @@ async fn init_gateway(
if shard_count < 16 { if shard_count < 16 {
scheme = ShardScheme::Auto; scheme = ShardScheme::Auto;
} else { } else {
let cluster_id = env::var("NOMAD_ALLOC_INDEX")?.parse::<u64>().unwrap(); let cluster_id = env::var("NOMAD_ALLOC_INDEX").or("0").parse::<u64>().unwrap();
let first_shard_id = 16 * cluster_id; let first_shard_id = 16 * cluster_id;
scheme = ShardScheme::try_from((first_shard_id..first_shard_id+16, shard_count)).unwrap(); scheme = ShardScheme::try_from((first_shard_id..first_shard_id+16, shard_count)).unwrap();