首页 > 解决方案 > 升级在 AWS 上运行的 YII2 项目后偶尔出现 503 错误

问题描述

我有一个在 AWS 上运行的 YII2 项目(elastic beanstalk (php 7.1) + 2 EC2 intances,一个应用程序负载均衡器(安装了 AWS WAF)+ RDS),很长时间没有更新,但运行良好。因为我想升级到更新的 PHP 版本,所以我还必须升级我的 YII2 项目。我运行了 composer(见下面的输出),在对代码进行了一些更改之后,一切都在我的本地机器上再次运行了。

我将项目上传回 AWS,并且“偶尔”收到 503 错误。错误会在不同的地方弹出,例如在我更新数据库中的某些内容并且页面被重定向时在下面截断的代码中。但碰巧相同的代码运行了 10 或 20 次完美,而下一次我收到错误。数据库中的更新每次都会成功,但有时我会在页面重定向时收到 503。

我真的对这个一无所知。有人知道问题可能是什么吗?(php仍然是7.1)

非常感谢!

缺口

Package operations: 27 installs, 34 updates, 2 removals
  - Removing bower-asset/typeahead.js (v0.11.1)
  - Removing bower-asset/jquery.inputmask (3.2.7)
  - Updating yiisoft/yii2-composer (2.0.5 => 2.0.9): Loading from cache
  - Removing bower-asset/jquery (2.2.3)
  - Installing bower-asset/jquery (3.4.1): Loading from cache
  - Removing bower-asset/bootstrap (v3.3.5)
  - Installing bower-asset/bootstrap (v3.4.1): Loading from cache
  - Updating ezyang/htmlpurifier (v4.8.0 => v4.12.0): Loading from cache
  - Removing bower-asset/yii2-pjax (v2.0.6)
  - Installing bower-asset/yii2-pjax (2.0.7.1): Loading from cache
  - Installing bower-asset/inputmask (3.3.11): Loading from cache
  - Updating cebe/markdown (1.1.1 => 1.2.1): Loading from cache
  - Updating yiisoft/yii2 (2.0.10 => 2.0.35): Loading from cache
  - Updating yiisoft/yii2-bootstrap (2.0.6 => 2.0.10): Loading from cache
  - Installing symfony/polyfill-php72 (v1.17.0): Loading from cache
  - Installing symfony/polyfill-mbstring (v1.17.0): Loading from cache
  - Installing symfony/polyfill-intl-idn (v1.17.0): Loading from cache
  - Installing symfony/polyfill-iconv (v1.17.0): Loading from cache
  - Installing doctrine/lexer (1.0.2): Loading from cache
  - Installing egulias/email-validator (2.1.17): Loading from cache
  - Updating swiftmailer/swiftmailer (v5.4.5 => v6.2.3): Loading from cache
  - Updating yiisoft/yii2-swiftmailer (2.0.6 => 2.1.2): Loading from cache
  - Removing bower-asset/jquery-ui (1.11.4)
  - Installing bower-asset/jquery-ui (1.12.1): Loading from cache
  - Updating yiisoft/yii2-jui (2.0.6 => 2.0.7): Loading from cache
  - Installing myclabs/deep-copy (1.9.5): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Updating setasign/fpdi (1.6.1 => v2.3.3): Loading from cache
  - Installing psr/log (1.1.3): Loading from cache
  - Updating mpdf/mpdf (v6.1.3 => v8.0.6): Loading from cache
  - Updating kartik-v/yii2-mpdf (v1.0.1 => v1.0.6): Loading from cache
  - Updating bizley/cookiemonster (1.0.1 => 1.0.2): Loading from cache
  - Updating kartik-v/yii2-krajee-base (v1.8.7 => v1.9.9): Loading from cache
  - Installing npm-asset/bootstrap (4.5.0): Loading from cache
  - Installing yiisoft/yii2-bootstrap4 (2.0.8): Loading from cache
  - Updating kartik-v/yii2-nav-x (v1.2.0 => v1.2.4): Loading from cache
  - Updating kartik-v/yii2-widget-datetimepicker (v1.4.3 => v1.4.7): Loading from cache
  - Installing kartik-v/yii2-bootstrap4-dropdown (v1.0.0): Loading from cache
  - Installing kartik-v/yii2-dialog (v1.0.4): Loading from cache
  - Removing kartik-v/yii2-grid (v3.1.1)
  - Installing kartik-v/yii2-grid (dev-master 7b7199c): Cloning 7b7199cd40 from cache
  - Updating kartik-v/yii2-widget-rangeinput (v1.0.1 => v1.0.2): Loading from cache
  - Removing kartik-v/bootstrap-tabs-x (v1.3.2)
  - Installing kartik-v/bootstrap-tabs-x (dev-master fb38942): Cloning fb3894222c from cache
  - Updating phpoffice/phpexcel (1.8.1 => 1.8.2): Loading from cache
  - Updating mikehaertl/php-tmpfile (1.1.0 => 1.1.4): Loading from cache
  - Updating codemix/yii2-excelexport (2.0.0 => 2.7.2): Loading from cache
  - Updating kartik-v/dependent-dropdown (v1.4.4 => v1.4.9): Loading from cache
  - Downgrading kartik-v/yii2-widget-depdrop (dev-master 6918ca6 => v1.0.4): Loading from cache
  - Updating yiisoft/yii2-codeception (2.0.5 => 2.0.6): Loading from cache
  - Installing opis/closure (3.5.4): Loading from cache
  - Updating yiisoft/yii2-debug (2.0.7 => 2.1.13): Loading from cache
  - Updating yiisoft/yii2-gii (2.0.5 => 2.2.1): Loading from cache
  - Updating fzaninotto/faker (v1.6.0 => v1.9.1): Loading from cache
  - Updating yiisoft/yii2-faker (2.0.3 => 2.0.4): Loading from cache
  - Installing symfony/polyfill-ctype (v1.17.0): Loading from cache
  - Installing twig/twig (v1.42.5): Loading from cache
  - Installing twig/extensions (v1.5.4): Loading from cache
  - Installing jaimeperez/twig-configurable-i18n (v1.2): Loading from cache
  - Installing gettext/languages (2.6.0): Loading from cache
  - Installing gettext/gettext (v3.6.1): Loading from cache
  - Installing whitehat101/apr1-md5 (v1.0.0): Loading from cache
  - Installing robrichards/xmlseclibs (3.1.0): Loading from cache
  - Installing simplesamlphp/saml2 (v3.1.6): Loading from cache
  - Installing simplesamlphp/simplesamlphp (v1.15.2): Loading from cache
  - Installing kartik-v/yii2-date-range (v1.6.9): Loading from cache
  - Installing select2/select2 (4.0.13): Loading from cache
  - Removing kartik-v/yii2-widget-activeform (dev-master 2807832)
  - Installing kartik-v/yii2-widget-activeform (dev-master 4d578ff): Cloning 4d578ff550 from cache
  - Removing kartik-v/yii2-widget-select2 (dev-master e135c25)
  - Installing kartik-v/yii2-widget-select2 (dev-master d44105a): Cloning d44105a4cb from cache

public function actionUpdate($id)
{
    URLCheck::checkBeschikbaarBudgetID($id);

    $model = $this->findModel($id);

    if ($model->load(Yii::$app->request->post()) && $model->save()) {
        return $this->redirect(['index', 'id'=>$model->id]);

    } else {
        return $this->render('update', [
                'model' => $model,
        ]);
    }
}

标签: amazon-web-servicesyii2

解决方案


推荐阅读