0

My sails.js application works fine on localhost but fails on heroku.

I have below settings in my production.js

  port: process.env.PORT || 1337,
  environment: process.env.NODE_ENV || 'development',

Still getting below messages and deployment fails;

2015-02-10T03:54:55.089482+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug read /app/config/locales/de.json for locale: de
2015-02-10T03:54:55.089220+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug will write to /app/config/locales/fr.json
2015-02-10T03:54:55.089261+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug read /app/config/locales/fr.json for locale: fr
2015-02-10T03:54:55.089453+00:00 app[web.1]: Tue, 10 Feb 2015 03:54:55 GMT i18n:debug will write to /app/config/locales/de.json
2015-02-10T03:54:55.138917+00:00 app[web.1]: designed for a production environment, as it will leak
2015-02-10T03:54:55.138919+00:00 app[web.1]: memory, and will not scale past a single process.
2015-02-10T03:54:55.393772+00:00 app[web.1]: http hook loaded successfully.
2015-02-10T03:54:55.396900+00:00 app[web.1]: sockets hook loaded successfully.
2015-02-10T03:54:55.397665+00:00 app[web.1]: Located 0 user hook(s)...
2015-02-10T03:54:55.413955+00:00 app[web.1]: Setting default Express view engine to jade...
2015-02-10T03:54:55.415525+00:00 app[web.1]: Loading adapter ( sails-mongo ) for user  from `node_modules` directory...
2015-02-10T03:54:55.394180+00:00 app[web.1]: Configuring socket (ws://) server...
2015-02-10T03:54:55.397318+00:00 app[web.1]: Loading user hooks...
2015-02-10T03:54:55.397942+00:00 app[web.1]: views hook loaded successfully.
2015-02-10T03:54:55.414283+00:00 app[web.1]: Initialized 0 user hook(s)...
2015-02-10T03:54:55.414314+00:00 app[web.1]: userhooks hook loaded successfully.
2015-02-10T03:54:55.415058+00:00 app[web.1]: Forcing Waterline to use `migrate: "safe" strategy (since this is production)
2015-02-10T03:54:55.606849+00:00 app[web.1]: Starting ORM...
2015-02-10T03:54:55.771204+00:00 app[web.1]: pubsub hook loaded successfully.
2015-02-10T03:54:55.931003+00:00 app[web.1]: Grunt :: >> Local Npm module "grunt-simple-mocha" not found. Is it installed?
2015-02-10T03:54:55.769438+00:00 app[web.1]: orm hook loaded successfully.
2015-02-10T03:54:56.159039+00:00 app[web.1]: Grunt :: Running "clean:dev" (clean) task
2015-02-10T03:54:56.180324+00:00 app[web.1]: Grunt :: >> Destination not written because compiled files were empty.
2015-02-10T03:54:56.184386+00:00 app[web.1]: Grunt :: Running "copy:dev" (copy) task
2015-02-10T03:54:56.180479+00:00 app[web.1]: Grunt :: Running "less:dev" (less) task
2015-02-10T03:54:56.162834+00:00 app[web.1]: Grunt :: Running "jst:dev" (jst) task
2015-02-10T03:54:56.729594+00:00 app[web.1]: Grunt :: , copied 542 files
2015-02-10T03:54:56.729493+00:00 app[web.1]: Grunt :: Created 4 directories
2015-02-10T03:54:56.730009+00:00 app[web.1]: Grunt :: Running "coffee:dev" (coffee) task
2015-02-10T03:54:56.856265+00:00 app[web.1]: Grunt :: Running "concat:js" (concat) task
2015-02-10T03:54:57.062061+00:00 app[web.1]: Grunt :: File ".tmp/public/concat/production.js" created.
2015-02-10T03:54:57.063749+00:00 app[web.1]: Grunt :: File ".tmp/public/concat/production.css" created.
2015-02-10T03:54:57.064113+00:00 app[web.1]: Grunt :: Running "uglify:dist" (uglify) task
2015-02-10T03:54:57.062590+00:00 app[web.1]: Grunt :: Running "concat:css" (concat) task
2015-02-10T03:55:53.360980+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-02-10T03:55:53.360980+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-02-10T03:55:54.179225+00:00 heroku[web.1]: Process exited with status 137
2015-02-10T03:55:54.193814+00:00 heroku[web.1]: State changed from starting to crashed

Please advise, thanks.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
aug70co
  • 3,965
  • 5
  • 30
  • 44
  • what port are you using, is that port already on use on the webserver? – arkoak Feb 10 '15 at 06:26
  • Port is set from environment => "port: process.env.PORT || 1337", port is 1337 when running on local. – aug70co Feb 10 '15 at 12:18
  • are you running another app on the same server which is using the same $PORT env variable? you can always try to explicity set a port in production. Also would be a good idea to check verbose log by using the --verbose flag when lifting sails – arkoak Feb 10 '15 at 12:52
  • I already have "silly" level logging, more verbose than verbose and the above post is that output. I suspect grunt taking too long for sails to lift and boot times out??? Not really sure... – aug70co Feb 11 '15 at 02:01

3 Answers3

3

You app is running in production mode. I can tell this because of Forcing Waterline to use `migrate: "safe" strategy (since this is production) and the concat/uglify tasks are running.

It is possible that this process (concat/uglify) is busting the allocated memory. I have seen this when deploying on small heroku instances with a lot of js/css to process. You might want to try the https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt to run grunt on deploy instead of launch.

See http://blog.mdarveau.com/2014/10/20/deploying-to-heroku for my experience on deploying a sails app to heroku.

The following part from the logs is weird though:

2015-02-10T03:54:55.138917+00:00 app[web.1]: designed for a production environment, as it will leak
2015-02-10T03:54:55.138919+00:00 app[web.1]: memory, and will not scale past a single process.
Manuel Darveau
  • 4,585
  • 5
  • 26
  • 36
  • 1
    Installing that buildpack resolved the issue. My configuration was correct, I didn't have to change anything except Grunt tasks. I knew there was something wrong with them. I renamed the sails default prod task to heroku and added an empty prod task. App starts fine now! Thank you! – aug70co Feb 12 '15 at 18:53
0

Set migrate: 'alter' in config/models.js

Arunabh Das
  • 13,212
  • 21
  • 86
  • 109
0

quick (temporary) solution is just remove production flag

delete process.env.NODE_ENV;
adros
  • 111
  • 3