fusenapi/config_replica_id.sh

34 lines
781 B
Bash
Raw Normal View History

2023-07-30 11:25:59 +00:00
#!/bin/bash
replica_id=5
change_config(){
server_name=$1
config_file="server/${server_name}/etc/${server_name}.yaml"
# 无论ReplicaId存在与否,都重置replica_id
((replica_id+=5))
if ! grep -q "ReplicaId:" "$config_file"; then
sed -i "s/^Port:.*$/&\nReplicaId: $replica_id/" "$config_file"
echo "Added ReplicaId: $replica_id to $config_file"
else
exist_id=$(grep -oP "ReplicaId:\s*\K[0-9]+" "$config_file")
sed -i "s/^ReplicaId:.*$/ReplicaId: $replica_id/" "$config_file"
echo "Updated ReplicaId to $replica_id in $config_file"
fi
}
# 读取server目录,忽略指定的三个目录
2023-08-22 08:27:05 +00:00
server_dirs=($(cd server && ls | grep -vE "backend|product-model"))
2023-07-30 11:25:59 +00:00
for server_dir in "${server_dirs[@]}"; do
change_config $server_dir
2023-08-22 08:27:05 +00:00
done