我正在尝试将我的一些代码推送到实时。我正在使用 aws codebuild 和 bitbucket 管道进行部署。当我尝试推送我的更改时,管道循环了 40 分钟,最终在一次失败后...
我正在尝试将我的一些代码推送到实时。我正在使用 aws codebuild 和 bitbucket 管道进行部署。当我尝试推送更改时,管道循环 40 分钟,一旦 codebuild 失败,管道最终会失败。检查日志,这是失败前发生的最后一件事。
Step 4/5 : RUN bundle exec rake db:migrate -X -s -q
---> Running in c556f46950e3
WARNING: Use strings for Figaro configuration. true was converted to "true".
rake aborted!
Mysql2::Error: Can't connect to MySQL server (110)
之后也会出现这个错误。
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
W, [2024-08-06T14:11:25.992477 #6] WARN -- : Creating scope :active. Overwriting existing method Professional.active.
I, [2024-08-06T14:13:26.227433 #6] INFO -- [Bugsnag]: Notifying https://notify.bugsnag.com of Mysql2::Error
D, [2024-08-06T14:13:26.318774 #6] DEBUG -- [Bugsnag]: Request to https://notify.bugsnag.com completed, status: 200
D, [2024-08-06T14:13:26.325314 #6] DEBUG -- [Bugsnag]: Not notifying Mysql2::Error due to ignore being signified in internal middlewares
The command '/bin/sh -c bundle exec rake db:migrate -X -s -q' returned a non-zero code: 1
我正在使用 ruby on rails。我担心我处理数据库的方式可能存在问题,但我希望有人可以指出在哪里检查问题。
我尝试清理 ruby on rails 中的迁移并再次部署。(不幸的是,我手动删除了文件,而不是正确的方法)
我尝试更新我的 rds 实例,因为他们说需要更新
EC2 安全组已正确分配给我的 RDS。
更多背景信息:在我尝试推送此新代码之前,此管道运行良好,因此我认为它可能与代码有关。如果我可以提供更多背景信息,请告诉我
branches:
develop:
- step:
name: create & push image
script:
- aws/codebuild.sh demo company-demo
- step:
name: deploy
deployment: staging
script:
- sed -i "s/TAGTOSET/demo-$BITBUCKET_COMMIT/g" ./aws/demo/ecs/task.json
- export TASK_VERSION=$(aws ecs register-task-definition --cli-input-json file://aws/demo/ecs/task.json | jq --raw-output '.taskDefinition.revision')
- echo "Registered ECS Task Definition $TASK_VERSION"
- aws ecs update-service --cluster demo --service company --task-definition demo-company:$TASK_VERSION --desired-count 1 --force-new-deployment
- step:
name: whenever deploy
script:
- sed -i "s/TAGTOSET/demo-$BITBUCKET_COMMIT/g" ./aws/demo/ecs/cron-task.json
- export TASK_VERSION=$(aws ecs register-task-definition --cli-input-json file://aws/demo/ecs/cron-task.json | jq --raw-output '.taskDefinition.revision')
- echo "Registered ECS Task Definition $TASK_VERSION"
- ECS_CLUSTER=demo TASK_DEFINITION=demo-cron ECS_CONTAINER=ruby AWS_REGION=ca-central-1 elastic_whenever -i demo -f config/schedule.rb
aws/codebuild.sh
PROJECT_ENV=$1
项目名称=$2
标签=\'$PROJECT_ENV-$BITBUCKET_COMMIT\'
echo \'开始构建项目:$PROJECT_NAME,标签为:$TAG\'BUILD_INFO= aws codebuild start-build --project-name $PROJECT_NAME --source-version $BITBUCKET_BRANCH --environment-variables-override name=TAG,value=$TAG
echo \'构建信息:$BUILD_INFO\'
BUILD_ID= echo $BUILD_INFO | jq -r '.build.id'
while true;doBUILD_STATUS= aws codebuild batch-get-builds --ids $BUILD_ID | jq -r '.builds[0].buildStatus'
echo \'当前构建状态:$BUILD_STATUS\'
如果 [[ $BUILD_STATUS == \'SUCCEEDED\' ]]; thenecho $BUILD_STATUSexit 0elif [[ $BUILD_STATUS == \'IN_PROGRESS\' ]]; thenecho \'构建正在进行中\'sleep 10elseecho \'构建失败,状态为:$BUILD_STATUS\'exit 1;fidone