javascript - 简单更新后 sails 无法升起

标签 javascript node.js amazon-web-services nginx sails.js

我有一个在 aws elastic beanstalk 上运行的服务器。一切都很好。但是今天在应用更新时(绝对与所用模块的配置或版本控制无关)只是在网络应用程序的某些文本中添加了几个词(字面意思是“狗”这个词)。该应用程序开始崩溃并出现 502 nginx 网关错误。我认为这是因为该应用程序不活泼。我去恢复了更改(尽管我认为我不必这样做)。问题仍然存在。

尝试升起/启动 sails 应用程序时,我的输出如下。

    Failed to load helper `web/auth/validate-user-password` as a machine!
A hook (`helpers`) failed to load!
Failed to lift app: ImplementationError: Sorry, could not interpret "web/auth/validate-user-password" because its underlying implementation has a problem:
------------------------------------------------------
• The `cacheable` property is no longer supported.  (Please use `sideEffects: 'cacheable' instead.)
------------------------------------------------------

If you are the maintainer of "web/auth/validate-user-password", then you can change its implementation to solve the problem above.  Otherwise, please file a bug report with the maintainer, or fork your own copy and fix that.
 [?] See https://sailsjs.com/support for help.
    at flaverr (/var/app/current/node_modules/flaverr/index.js:77:15)
    at helpBuildMachine (/var/app/current/node_modules/sails/node_modules/machine/lib/private/help-build-machine.js:127:11)
    at Function.build (/var/app/current/node_modules/sails/node_modules/machine/lib/build.js:52:10)
    at /var/app/current/node_modules/sails/lib/hooks/helpers/load-helpers.js:51:49
    at /var/app/current/node_modules/@sailshq/lodash/lib/index.js:3228:15
    at baseForOwn (/var/app/current/node_modules/@sailshq/lodash/lib/index.js:2199:14)
    at /var/app/current/node_modules/@sailshq/lodash/lib/index.js:3198:18
    at Function.<anonymous> (/var/app/current/node_modules/@sailshq/lodash/lib/index.js:3501:13)
    at /var/app/current/node_modules/sails/lib/hooks/helpers/load-helpers.js:37:9
    at helpBuildDictionary (/var/app/current/node_modules/sails/node_modules/include-all/lib/help-build-dictionary.js:135:10)
    at Function.module.exports.optional (/var/app/current/node_modules/sails/node_modules/include-all/index.js:67:10)
    at Hook.loadHelpers (/var/app/current/node_modules/sails/lib/hooks/helpers/load-helpers.js:21:14)
    at Hook.initialize (/var/app/current/node_modules/sails/lib/hooks/helpers/index.js:28:19)
    at Hook.wrapper [as initialize] (/var/app/current/node_modules/@sailshq/lodash/lib/index.js:3250:19)
    at /var/app/current/node_modules/sails/lib/hooks/index.js:88:16
    at /var/app/current/node_modules/async/dist/async.js:486:20
(You are seeing the above error message because no custom callback was programmatically provided to `.lift()`.)
A hook (`orm`) failed to load!

这就是我在 package.json 中看到的内容,以备不时之需。

{
  "name": "sails-xxxxxxx-seed",
  "private": true,
  "version": "0.0.3-147",
  "description": "a Sails application",
  "keywords": [],
  "dependencies": {
    "async": "2.0.1",
    "aws-sdk": "^2.41.0",
    "bcryptjs": "2.3.0",
    "connect-redis": "3.3.0",
    "flaverr": "^1.1.1",
    "lodash": "3.10.1",
    "machinepack-http": "3.1.2",
    "moment-timezone": "0.5.13",
    "pdfmake": "0.1.28",
    "sails": "^1.0.0-32",
    "sails-hook-orm": "^2.0.0-0",
    "sails-hook-sockets": "^1.0.1",
    "sails-mysql": "^1.0.0-13",
    "sails-stdlib": "^0.7.1",
    "sails.io.js": "1.1.9",
    "serve-static": "1.12.3",
    "socket.io-client": "1.7.3",
    "socket.io-redis": "3.1.0",
    "uuid": "3.0.1"
  },
  "devDependencies": {
    "@angular/animations": "~4.1.3",
    "@angular/common": "~4.1.3",
    "@angular/compiler": "~4.1.3",
    "@angular/compiler-cli": "~4.1.3",
    "@angular/core": "~4.1.3",
    "@angular/forms": "~4.1.3",
    "@angular/http": "~4.1.3",
    "@angular/platform-browser": "~4.1.3",
    "@angular/platform-browser-dynamic": "~4.1.3",
    "@angular/platform-server": "~4.1.3",
    "@angular/router": "~4.1.3",
    "@angular/upgrade": "~4.1.3",
    "@swimlane/ngx-datatable": "^8.0.0",
    "@types/jasmine": "^2.5.47",
    "@types/node": "^6.0.48",
    "angular-pipes": "^6.5.1",
    "angular-router-loader": "^0.6.0",
    "angular2-in-memory-web-api": "0.0.21",
    "angular2-moment": "^1.3.3",
    "angular2-template-loader": "^0.6.0",
    "angular2-text-mask": "^8.0.1",
    "awesome-typescript-loader": "^3.1.2",
    "babel-core": "^6.25.0",
    "babel-loader": "^7.0.0",
    "babel-preset-env": "^1.5.2",
    "babel-preset-es2015": "^6.24.1",
    "chart.js": "^2.5.0",
    "clean-webpack-plugin": "0.1.16",
    "clipboard": "^1.6.1",
    "copy-webpack-plugin": "4.0.1",
    "core-js": "^2.4.1",
    "css-loader": "0.27.3",
    "debug": "^2.6.8",
    "ejs-loader": "0.3.0",
    "eslint": "3.19.0",
    "extract-text-webpack-plugin": "2.1.0",
    "file-loader": "^0.11.1",
    "glob": "^7.1.1",
    "ie-shim": "^0.1.0",
    "json2csv": "^3.7.3",
    "knex": "0.13.0",
    "less": "2.7.2",
    "less-loader": "4.0.1",
    "mime-types": "2.1.15",
    "mocha": "^3.2.0",
    "mydatepicker": "^1.9.2",
    "ng-sidebar": "^4.1.1",
    "ng2-charts": "^1.5.0",
    "ng2-table": "^1.3.2",
    "ng2-toastr": "^4.0.1",
    "ng2-validation": "^4.1.0",
    "ngx-bootstrap": "^1.6.6",
    "ngx-progressbar": "^2.0.0",
    "node-sass": "^4.5.2",
    "primeng": "^4.0.0",
    "prompt": "1.0.0",
    "raw-loader": "^0.5.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "sass-loader": "^6.0.3",
    "semver": "^5.3.0",
    "to-string-loader": "^1.1.4",
    "typescript": "~2.2.1",
    "url-loader": "^0.5.8",
    "waterline-utils": "^1.3.12",
    "webpack": "^2.2.1",
    "webpack-livereload-plugin": "^0.11.0",
    "webpack-merge": "^0.15.0",
    "webpack-watch-livereload-plugin": "0.0.1",
    "zone.js": "~0.6.26"
  },
  "scripts": {
    "start": "NODE_ENV=production node app.js",
    "test": "npm run lint && npm run custom-tests && echo 'Done.'",
    "lint": "node ./node_modules/eslint/bin/eslint . --max-warnings=0 && echo '✔  Your code looks good.'",
    "custom-tests": "echo \"(No other custom tests yet.)\" && echo",
    "version": "node -e 'process.stdout.write((require(\"./package.json\").version))'",
    "bump": "node scripts/bump.js",
    "debug": "node debug app.js",
    "deploy-staging": "sails_environment=web_staging npm run bump && sails_environment=web_staging npm run deploy",
    "deploy-demo": "sails_environment=web_demo npm run bump && npm run deploy",
    "deploy": "cp -r eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && npm run zip && rm .ebbootstrap.sh && node scripts/publish-static-assets && node scripts/deploy-to-eb",
    "zip": "mkdir -p .tmp && rm .tmp/deploy.zip &> /dev/null; zip -9 -r --exclude=node_modules/* --exclude=.tmp/* --exclude=.DS_Store --exclude=.git/* --exclude=config/local.js ./.tmp/deploy.zip .",
    "deploy-alerts-staging": "sails_environment=alerts_staging npm run bump && sails_environment=alerts_staging npm run deploy-alerts",
    "deploy-alerts": "cp eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && cp eb/apps/alerts/cron.yaml cron.yaml && npm run zip-backend && rm cron.yaml .ebbootstrap.sh && node scripts/deploy-to-eb",
    "deploy-rollup-staging": "sails_environment=rollup_staging npm run bump && sails_environment=rollup_staging npm run deploy-rollup",
    "deploy-rollup": "cp eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && cp eb/apps/rollup/cron.yaml cron.yaml && npm run zip-backend && rm cron.yaml .ebbootstrap.sh && node scripts/deploy-to-eb",
    "deploy-devices-staging": "sails_environment=devices_staging npm run bump && sails_environment=devices_staging npm run deploy-devices",
    "deploy-devices": "cp eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && npm run zip-backend && rm .ebbootstrap.sh && node scripts/deploy-to-eb",
    "deploy-device-sim": "cp eb/bootstrap/device_sim.sh .ebbootstrap.sh && cp eb/apps/device-sim/cron.yaml cron.yaml && npm run zip-backend && rm cron.yaml .ebbootstrap.sh && sails_environment=device_sim npm run bump && sails_environment=device_sim node scripts/deploy-to-eb",
    "zip-backend": "mkdir -p .tmp && rm .tmp/deploy.zip &> /dev/null; zip -9 -r --exclude=node_modules/* --exclude=.tmp/* --exclude=.DS_Store --exclude=.git/* --exclude=src/* --exclude=config/local.js ./.tmp/deploy.zip ."
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "xxxxxxxxxx.git"
  },
  "author": "xxxxxx",
  "license": ""
}

下面是validate-user-password.js

module.exports = {
  friendlyName: 'Validate user password (strict)',
  description: 'Strictly validate a string as the potential "password" for a user.',
  cacheable: true,
  sync: true,
  inputs: {
    string: {
      description: 'The string to validate as a password.',
      required: true,
      example: 'abcd1234',
    }
  },
  exits: {
    success: {
      description: 'The specified string is 100% valid.'
    },
    notValid: {
      description: 'The specified string is not a valid password.'
    },
  },
  fn: function (inputs,exits) {
    // Coerce
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Since we don't need to support `strict: false` for this validator (it is ALWAYS strict), then we can
    // just skip this part.  (Also no need for the "notStrictlyValid" exit, output from the success exit,
    // or the `strict` input)
    //
    // n/a
    // Validate
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    // • Must be long enough.
    if (inputs.string.length < 7) {
      return exits.notValid(new Error('Password must consist of at least 7 characters.'));
    }

    // • Must not be too long.
    if (inputs.string.length > 72) {
      return exits.notValid(new Error('Password must not contain more than 72 characters.'));
    }

    return exits.success();
  }
};

最佳答案

确实,这可能是 Sails 本身的更新导致的。您是否为 validate-user-password.js 尝试了以下配置?

module.exports = {
  friendlyName: 'Validate user password (strict)',
  description: 'Strictly validate a string as the potential "password" for a user.',
  sideEffects: 'cacheable',
  sync: true,
  /* ... rest of content ... */
}

关于javascript - 简单更新后 sails 无法升起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46918849/

相关文章:

php - 转储到 JavaScript 数组的 HTML 文本破坏了我的代码

mysql - 使用 For 循环迭代异步函数(数据库查询,Node.js)

node.js - 等待异步方法完成

amazon-web-services - 用于附加 .html 或 index.html 的 AWS S3 路由规则

javascript - 如何在循环中测试 readystate 和 status 以避免 else 分支?

javascript - 类型和实现它的类的命名约定是什么?

Javascript:如何将数字四舍五入到两位非零小数

javascript - 随机重定向

python - AWS Elastic Beanstalk CLI 不提示创建新的 key 对

amazon-web-services - Elasticsearch 快照失败并出现 RepositoryMissingException