Sails js和Heroku:应用程序中发生错误,无法提供您的页面。

时间:2017-02-21 15:12:52

标签: heroku sails.js

我需要帮助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但是没有发生。 感谢。

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

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

    你的.sailsrc文件中的
  1. - 你需要关闭grunt(当做本地开发时,注释掉它) -

    {“generators”:{“modules”:{}},“hooks”:{“grunt”:false}}

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

    路径:{公共:__目录名+ '/ .. / .. /网络/'}

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

  4. 您可能还需要执行其他一些操作,例如确保您的站点设置为使用redis或某种类型的db用于套接字和会话。您可能还想使用像pm2这样的东西来实际加载您的应用程序,就像您使用更大的dyno一样,然后您可以在同一个dyno上运行多个sails应用程序实例。

    结帐http://sailsjs.com/documentation/concepts/deployment/hosting#?deploying-to-heroku以获取更多信息,直接来自Sails.js