【问题标题】:Sails js and Heroku : An error occurred in the application and your page could not be served.Sails js 和 Heroku:应用程序发生错误,无法提供您的页面。
【发布时间】:2017-02-21 15:12:52
【问题描述】:

我需要有关 heroku 的帮助。我的应用程序运行良好,但今天无法运行。我没有修改任何文件。有人可以帮助我吗?我在 stackOverFlow 中关注了另一个帖子,但没有用。

我运行 heroku 日志:

 2017-02-21T14:51:12.588970+00:00 app[web.1]: Line 3997 in .tmp/public/concat/production.js
2017-02-21T14:51:12.588971+00:00 app[web.1]:  
2017-02-21T14:51:12.588971+00:00 app[web.1]: ------------------------------------------------------------------------
2017-02-21T14:51:12.589061+00:00 app[web.1]: 
2017-02-21T14:51:12.589124+00:00 app[web.1]: Looks like a Grunt error occurred--
2017-02-21T14:51:12.589185+00:00 app[web.1]: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
2017-02-21T14:51:12.589241+00:00 app[web.1]: Or if you're stuck, check out the troubleshooting tips below.
2017-02-21T14:51:12.589303+00:00 app[web.1]: 
2017-02-21T14:51:12.589958+00:00 app[web.1]: Troubleshooting tips:
2017-02-21T14:51:12.590030+00:00 app[web.1]: 
2017-02-21T14:51:12.590089+00:00 app[web.1]:  *-> Are "grunt" and related grunt task modules installed locally?  Run `npm install` if you're not sure.
2017-02-21T14:51:12.590133+00:00 app[web.1]: 
2017-02-21T14:51:12.590178+00:00 app[web.1]:  *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
2017-02-21T14:51:12.590247+00:00 app[web.1]: 
2017-02-21T14:51:12.590287+00:00 app[web.1]:  *-> Or maybe you don't have permissions to access the `.tmp` directory?
2017-02-21T14:51:12.590377+00:00 app[web.1]:      e.g., `/app/.tmp` ?
2017-02-21T14:51:12.590423+00:00 app[web.1]: 
2017-02-21T14:51:12.590468+00:00 app[web.1]:      If you think this might be the case, try running:
2017-02-21T14:51:12.592153+00:00 app[web.1]:      sudo chown -R 17728 /app/.tmp
2017-02-21T14:51:12.592214+00:00 app[web.1]: 
2017-02-21T14:51:30.670658+00:00 app[web.1]: Error: The hook `grunt` is taking too long to load.
2017-02-21T14:51:30.670679+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)
2017-02-21T14:51:30.670680+00:00 app[web.1]:     at Timeout.tooLong [as _onTimeout] (/app/node_modules/sails/lib/app/private/loadHooks.js:85:21)
2017-02-21T14:51:30.670682+00:00 app[web.1]:     at ontimeout (timers.js:365:14)
2017-02-21T14:51:30.670682+00:00 app[web.1]:     at tryOnTimeout (timers.js:237:5)
2017-02-21T14:51:30.670683+00:00 app[web.1]:     at Timer.listOnTimeout (timers.js:207:5)
2017-02-21T14:51:30.780591+00:00 heroku[web.1]: Process exited with status 0
2017-02-21T14:51:30.795109+00:00 heroku[web.1]: State changed from starting to crashed
2017-02-21T14:51:30.796348+00:00 heroku[web.1]: State changed from crashed to starting
2017-02-21T14:51:33.992516+00:00 heroku[web.1]: Starting process with command `npm start`
2017-02-21T14:51:36.040206+00:00 app[web.1]: 
2017-02-21T14:51:36.040223+00:00 app[web.1]: > estudioMate@0.0.0 start /app
2017-02-21T14:51:36.040224+00:00 app[web.1]: > node app.js
2017-02-21T14:51:36.040225+00:00 app[web.1]: 
2017-02-21T14:51:37.483529+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-02-21T14:51:37.483541+00:00 app[web.1]: designed for a production environment, as it will leak
2017-02-21T14:51:37.483542+00:00 app[web.1]: memory, and will not scale past a single process.
2017-02-21T14:51:37.602636+00:00 app[web.1]: Express midleware for passport
2017-02-21T14:51:37.621476+00:00 app[web.1]: Tue, 21 Feb 2017 14:51:37 GMT connect deprecated multipart: use parser (multiparty, busboy, formidable) npm module instead at 
node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:56:20
2017-02-21T14:51:37.621689+00:00 app[web.1]: Tue, 21 Feb 2017 14:51:37 GMT connect deprecated limit: Restrict request size at location of read at node_modules/express/node_modules/connect/lib/middleware/multipart.js:86:15
2017-02-21T14:51:37.656950+00:00 app[web.1]: The default `sails-disk` adapter is not designed for use as a production database;
2017-02-21T14:51:37.657085+00:00 app[web.1]: Instead, please use another adapter; e.g. sails-postgresql or sails-mongo.
2017-02-21T14:51:37.657042+00:00 app[web.1]: (it stores the entire contents of your database in memory)
2017-02-21T14:51:37.657116+00:00 app[web.1]: For more info, see: http://sailsjs.org/documentation/concepts/deployment
2017-02-21T14:51:37.657131+00:00 app[web.1]: To hide this warning message, enable `sails.config.orm.skipProductionWarnings`.
2017-02-21T14:51:37.657481+00:00 app[web.1]: 
2017-02-21T14:51:37.657506+00:00 app[web.1]: A project-wide `sails.config.models.migrate` setting has not been configured for this app.
2017-02-21T14:51:37.657550+00:00 app[web.1]: Since the NODE_ENV env variable is set to "production", auto-migration will be disabled automatically.
2017-02-21T14:51:37.657575+00:00 app[web.1]: (i.e. `migrate: 'safe'`)
2017-02-21T14:51:39.409768+00:00 app[web.1]: ** Grunt :: An error occurred. **
2017-02-21T14:51:39.410163+00:00 app[web.1]: 
2017-02-21T14:51:39.410166+00:00 app[web.1]: ------------------------------------------------------------------------
2017-02-21T14:51:39.410167+00:00 app[web.1]: Aborted due to warnings.
2017-02-21T14:51:39.410168+00:00 app[web.1]: Running "uglify:dist" (uglify) task
2017-02-21T14:51:39.410168+00:00 app[web.1]: JS_Parse_Error {
2017-02-21T14:51:39.410169+00:00 app[web.1]:   message: 'SyntaxError: Unexpected token punc «}», expected punc «:»',
2017-02-21T14:51:39.410170+00:00 app[web.1]:   filename: '../concat/production.js',
2017-02-21T14:51:39.410171+00:00 app[web.1]:   line: 3997,
2017-02-21T14:51:39.410171+00:00 app[web.1]:   col: 31,
2017-02-21T14:51:39.410172+00:00 app[web.1]:   pos: 284354,
2017-02-21T14:51:39.410187+00:00 app[web.1]: >> Uglifying source .tmp/public/concat/production.js failed.
2017-02-21T14:51:39.410183+00:00 app[web.1]:   stack: 'Error\n  at new JS_Parse_Error (<anonymous>:1534:18)\n  at js_error (<anonymous>:1542:11)\n  at croak (<anonymous>:2089:9)\n  at token_error (<anonymous>:2097:9)\n  at expect_token (<anonymous>:2110:9)\n  at expect (<anonymous>:2113:36)\n  at eval (<anonymous>:2686:13)\n  at eval (<anonymous>:2136:24)\n  at expr_atom (<anonymous>:2616:35)\n  at maybe_unary (<anonymous>:2792:19)\n  at expr_ops (<anonymous>:2827:24)\n  at maybe_conditional (<anonymous>:2832:20)\n  at maybe_assign (<anonymous>:2856:20)\n  at expression (<anonymous>:2875:20)\n  at expr_list (<anonymous>:2641:24)\n  at subscripts (<anonymous>:2775:30)\n  at subscripts (<anonymous>:2752:20)\n  at expr_atom (<anonymous>:2628:20)\n  at maybe_unary (<anonymous>:2792:19)\n  at expr_ops (<anonymous>:2827:24)\n  at maybe_conditional (<anonymous>:2832:20)\n  at maybe_assign (<anonymous>:2856:20)\n  at expression (<anonymous>:2875:20)\n  at simple_statement (<anonymous>:2314:55)\n  at eval (<anonymous>:2183:19)\n  at eval (<anonymous>:2136:24)\n  at block_ (<anonymous>:2429:20)\n  at eval (<anonymous>:2401:25)\n  at function_ (<anonymous>:2407:15)\n  at expr_atom (<anonymous>:2622:24)\n  at maybe_unary (<anonymous>:2792:19)\n  at expr_ops (<anonymous>:2827:24)\n  at maybe_conditional (<anonymous>:2832:20)\n  at maybe_assign (<anonymous>:2856:20)\n  at maybe_assign (<anonymous>:2864:32)\n  at expression (<anonymous>:2875:20)\n  at simple_statement (<anonymous>:2314:55)\n  at eval (<anonymous>:2183:19)\n  at eval (<anonymous>:2136:24)\n  at block_ (<anonymous>:2429:20)\n  at eval (<anonymous>:2401:25)\n  at function_ (<anonymous>:2407:15)\n  at expr_atom (<anonymous>:2622:24)\n  at maybe_unary (<anonymous>:2792:19)\n  at expr_ops (<anonymous>:2827:24)\n  at maybe_conditional (<anonymous>:2832:20)\n  at maybe_assign (<anonymous>:2856:20)\n  at expression (<anonymous>:2875:20)\n  at expr_list (<anonymous>:2641:24)\n  at eval (<anonymous>:2651:23)\n  at eval (<anonymous>:2136:24)\n  at expr_atom (<anonymous>:2614:35)\n  at maybe_unary (<anonymous>:2792:19)\n  at expr_ops (<anonymous>:2827:24)\n  at maybe_conditional (<anonymous>:2832:20)\n  at maybe_assign (<anonymous>:2856:20)\n  at expression (<anonymous>:2875:20)\n  at expr_list (<anonymous>:2641:24)\n  at subscripts (<anonymous>:2775:30)\n  at subscripts (<anonymous>:2752:20)\n  at subscripts (<anonymous>:2772:20)\n  at subscripts (<anonymous>:2752:20)\n  at expr_atom (<anonymous>:2628:20)\n  at maybe_unary (<anonymous>:2792:19)\n  at expr_ops (<anonymous>:2827:24)\n  at maybe_conditional (<anonymous>:2832:20)\n  at maybe_assign (<anonymous>:2856:20)\n  at expression (<anonymous>:2875:20)\n  at simple_statement (<anonymous>:2314:55)\n  at eval (<anonymous>:2183:19)\n  at eval (<anonymous>:2136:24)\n  at eval (<anonymous>:2904:23)\n  at Object.parse (<anonymous>:2915:7)\n  at /app/node_modules/grunt-contrib-uglify/tasks/lib/uglify.js:54:27\n  at Array.forEach (native)\n  at Object.exports.minify (/app/node_modules/grunt-contrib-uglify/tasks/lib/uglify.js:37:11)\n  at /app/node_modules/grunt-contrib-uglify/tasks/uglify.js:156:25\n  at Array.forEach (native)\n  at Object.<anonymous> (/app/node_modules/grunt-contrib-uglify/tasks/uglify.js:77:16)\n  at Object.<anonymous> (/app/node_modules/grunt/lib/grunt/task.js:255:15)\n  at Object.thisTask.fn (/app/node_modules/grunt/lib/grunt/task.js:73:16)\n  at Object.<anonymous> (/app/node_modules/grunt/lib/util/task.js:294:30)\n  at Task.runTaskFn (/app/node_modules/grunt/lib/util/task.js:244:24)\n  at Task.<anonymous> (/app/node_modules/grunt/lib/util/task.js:293:12)\n  at /app/node_modules/grunt/lib/util/task.js:220:11\n  at _combinedTickCallback (internal/process/next_tick.js:67:7)\n  at process._tickCallback (internal/process/next_tick.js:98:9)\n' }
2017-02-21T14:51:39.410187+00:00 app[web.1]: Warning: Uglification failed.
2017-02-21T14:51:39.410188+00:00 app[web.1]: SyntaxError: Unexpected token punc «}», expected punc «:». 
2017-02-21T14:51:39.410189+00:00 app[web.1]: Line 3997 in .tmp/public/concat/production.js
2017-02-21T14:51:39.410189+00:00 app[web.1]:  
2017-02-21T14:51:39.410190+00:00 app[web.1]: ------------------------------------------------------------------------
2017-02-21T14:51:39.410287+00:00 app[web.1]: 
2017-02-21T14:51:39.410347+00:00 app[web.1]: Looks like a Grunt error occurred--
2017-02-21T14:51:39.410405+00:00 app[web.1]: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
2017-02-21T14:51:39.410465+00:00 app[web.1]: Or if you're stuck, check out the troubleshooting tips below.
2017-02-21T14:51:39.410527+00:00 app[web.1]: 
2017-02-21T14:51:39.411169+00:00 app[web.1]: Troubleshooting tips:
2017-02-21T14:51:39.411248+00:00 app[web.1]: 
2017-02-21T14:51:39.411309+00:00 app[web.1]:  *-> Are "grunt" and related grunt task modules installed locally?  Run `npm install` if you're not sure.
2017-02-21T14:51:39.411377+00:00 app[web.1]: 
2017-02-21T14:51:39.411435+00:00 app[web.1]:  *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
2017-02-21T14:51:39.411489+00:00 app[web.1]: 
2017-02-21T14:51:39.411544+00:00 app[web.1]:  *-> Or maybe you don't have permissions to access the `.tmp` directory?
2017-02-21T14:51:39.411755+00:00 app[web.1]: 
2017-02-21T14:51:39.411678+00:00 app[web.1]:      e.g., `/app/.tmp` ?
2017-02-21T14:51:39.411812+00:00 app[web.1]:      If you think this might be the case, try running:
2017-02-21T14:51:39.413647+00:00 app[web.1]:      sudo chown -R 59060 /app/.tmp
2017-02-21T14:51:39.413728+00:00 app[web.1]: 
2017-02-21T14:51:57.381050+00:00 app[web.1]: Error: The hook `grunt` is taking too long to load.
2017-02-21T14:51:57.381063+00:00 app[web.1]: Make sure it is triggering its `initialize()` callback, or else set `sails.config.grunt._hookTimeout to a higher value (currently 20000)
2017-02-21T14:51:57.381064+00:00 app[web.1]:     at Timeout.tooLong [as _onTimeout] (/app/node_modules/sails/lib/app/private/loadHooks.js:85:21)
2017-02-21T14:51:57.381066+00:00 app[web.1]:     at ontimeout (timers.js:365:14)
2017-02-21T14:51:57.381066+00:00 app[web.1]:     at tryOnTimeout (timers.js:237:5)
2017-02-21T14:51:57.381067+00:00 app[web.1]:     at Timer.listOnTimeout (timers.js:207:5)
2017-02-21T14:51:57.570097+00:00 heroku[web.1]: State changed from starting to crashed
2017-02-21T14:51:57.553867+00:00 heroku[web.1]: Process exited with status 0
2017-02-21T14:51:58.636986+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=c24795a8-27d7-490a-87e3-63217a2dce6c fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:51:58.812104+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=026d9527-41f1-4124-816b-d1a1b5735b4b fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:52:35.751663+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=d0e1a421-a1ad-4e01-bd95-32cee5e79dcb fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:52:48.270115+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=e60095d6-0a4c-4e8f-9ed9-04667531ce65 fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:53:59.766514+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=ba41e862-7e49-4a77-b943-2922b1787660 fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:56:37.383946+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=8c14b2fa-fde5-428c-a6c3-0bb9690613d9 fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:58:54.174763+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=273424e6-5eaa-4685-af19-5f8859466e3f fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:59:15.578510+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=b326c9f4-8552-4934-94c4-db22d0c6d4fa fwd="186.153.254.79" dyno= connect= service= status=503 bytes=
2017-02-21T14:59:17.342443+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=www.equipomate.com request_id=616ce76b-5753-461d-a520-01a2593efc75 fwd="186.153.254.79" dyno= connect= service= status=503 bytes=

我运行 npm install,再次 git heroku push 但没有发生。 谢谢。

【问题讨论】:

  • 你的意思是你的应用在 Heroku 上运行良好,但现在它停止了?或者你是说你可以在本地运行你的应用,但是当你推送到 Heroku 时它不起作用?
  • 您好,感谢您回答我。我的应用程序在本地运行,但是当我推送到 HEroku 时不起作用。

标签: heroku sails.js


【解决方案1】:

你需要做更多的工作来准备在 Heroku 上运行的风帆。首先,Sails 有一个固有的构建过程。默认情况下,当您推送到 Heroku 时,NODE_ENV 环境变量设置为 production。这将导致npm 不加载任何开发依赖项。查看这是否是唯一错误(我不确定是不是)的最快解决方法是将您的NODE_ENV env 变量设置为staging(或其他任何东西,只要它不是production)并尝试再次推动。这应该会加载您的开发依赖项,并且可能会让您走得更远。

最终,如果您要在 Heroku 上为 Sails 提供服务,您需要找到一种更好的部署方式。我建议查看这个heroku-sails 示例和包:https://github.com/chadn/heroku-sails

【讨论】:

    【解决方案2】:

    当我将sails.js 应用程序部署到heroku 时,我通常至少会执行以下操作 -

    1. 在您的 .sailsrc 文件中 - 您需要关闭 grunt(在进行本地开发时,将其注释掉)-

      {"generators": {"modules": {}},"hooks": {"grunt": false}}

    2. 然后,当 NODE_ENV 为 prod 时,您将需要配置静态资产以从编译目录加载,因此在 /config/env/production.js - 将变量添加到您的导出中 -

      路径:{public:__dirname+'/../../www/'}

    3. 在项目根目录中添加 www 文件夹并运行命令“grunt build”或“grunt buildProd”。然后,这将为 heroku 预编译所有资产,因为 grunt 可能需要很长时间才能加载/运行,并且可能会阻止您的应用程序启动。

    您可能还想做一些其他的事情,例如确保您的网站设置为使用 redis 或某种类型的 db 用于套接字和会话。您可能还想使用 pm2 之类的东西来实际加载您的应用程序,就好像您在一个更大的测功机上一样,然后您可以在同一个测功机上运行您的风帆应用程序的多个实例。

    结帐http://sailsjs.com/documentation/concepts/deployment/hosting#?deploying-to-heroku 直接从 Sails.js 获得更多信息

    【讨论】:

      猜你喜欢
      • 2019-03-26
      • 1970-01-01
      • 1970-01-01
      • 2014-06-27
      • 2021-11-29
      • 2013-11-24
      • 2017-02-25
      • 2017-08-16
      • 1970-01-01
      相关资源
      最近更新 更多