Runningaws ecs update-service --cluster cluster-name --service service-name --force-new-deployment --region ap-southeast-2
打开:
{
"service": {
"serviceArn": "arn:aws:ecs:ap-southeast-2:000000000000:service/service-name",
"serviceName": "service-name",
"clusterArn": "arn:aws:ecs:ap-southeast-2:000000000000:cluster/clustername",
"loadBalancers": [
{
"targetGroupArn": "arn:aws:elasticloadbalancing:ap-southeast-2:000000000000:targetgroup/targetgroupname",
"containerName": "containername",
"containerPort": 5000
}
],
"serviceRegistries": [],
"status": "ACTIVE",
"desiredCount": 1,
"runningCount": 1,
"pendingCount": 1,
"launchType": "FARGATE",
"platformVersion": "LATEST",
"taskDefinition": "arn:aws:ecs:ap-southeast-2:000000000000:task-definition/service-name:43",
:
并阻止我的外壳,直到我按下q
.这曾经工作得很好。我想我更新了我的 AWSCLI,它导致了这种情况。为什么会发生这种情况,如何避免它以更新 CI 脚本中的服务?
如 https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html 所述: 您可以将--no-cli-pager
选项添加到命令中,以禁用寻呼机以使用单个命令。
在您的特定示例中:
aws ecs update-service --cluster cluster-name --service service-name --force-new-deployment --region ap-southeast-2 --no-cli-pager
它仍然会将输出打印到命令行(但不会像以前一样通过打开 vim 来停止和阻止脚本的进一步命令)
这比禁用寻呼机或将输出重定向到/dev/null
要好,因为如果您愿意,您仍然可以看到输出。(如果您想保留输出,也可以将输出重定向到文件./output
)
我遇到了这种行为,并在找到 AWS 文档,如何使用 AWS_PAGER 环境变量
之前尝试了许多解决方法窗户:
C:> setx AWS_PAGER ""
Linux 和 MacOS:
export AWS_PAGER=""
是的,这是 AWS CLI 2 的默认行为。这应该可以解决您的问题(因为我认为没有内置的方法可以使其"安静"或沉默)。
AWS ECS update-service --service svcName --desired-count 1>/dev/null
我不建议回到旧版本,除非作为最后的手段。