Category: Sails (page 2 of 2)

Sails.js enable redis sockets allows you to use redis for sockets. Because sails.js uses, it consequently also allows you to set up redis for sockets. Enabling this behaviour is relatively easy.

To enable this, open up config/sockets.js and look up this block:

Now uncomment the options, configure the adapter and you’re done.

Q&A: sails.js enable jsonp


This is a question I had myself. Why, if I call /foo?callback=bar do I not get a jsonp response?


Out of the box, sails doesn’t enable jsonp support. In order to enable this, you have to change config/blueprints.js and add jsonp: true.

Q&A: Sails.js won’t run through forever.js


Since recent releases of sails.js, for some people it seems like sails won’t run using forever anymore.

On github, SuThaw asked:

I installed forever js with “npm install forever -g” and I run it like this “forever start app.js –prod”. when I open up my browser (http:, nothing shows up.


The answer, is a new “safety switch” that has been added to migrations. This safety switch protects you from accidentally erasing precious data from your database when changing the properties of models due to database errors. What happens, is that sails asks you a question, that requires user input to be answered and go away (continue the flow). Using forever, this never happens. The message sails gives you is:

Excuse my interruption, but it looks like this app does not have a project-wide “migrate” setting configured yet. (perhaps this is the first time you’re lifting it with models?)

And gives you the following options:

  1. safe – never auto-migrate my database(s). I will do it myself (by hand)
  2. alter – auto-migrate, but attempt to keep my existing data (experimental)
  3. drop – wipe/drop ALL my data and rebuild models every time I lift Sails

To fix this, all you have to do is add a default migrate option in config.models.js. You could, for instance, simply add safe:

Q&A: autoWatch false still pushes updates sails.js


The autoWatch configuration option for blueprints seems to be causing some confusion every now and then. Specifically, the question is:

Why, after disabling autoWatch by setting it to false, do I still receive updates from pubsub?


Taken from the sails documentation, the option autoWatch allows you to specify:

Whether to run in the find and findOne blueprint actions. Can be overridden on a per-model basis.

The function watches for newly created records for that specific model; not updates. The subscribe method however, is responsible for updates.

Found here, you can see sails uses a different option for pubsub:

If you want to disable pubsub, you can read how to do that on disabling pubsub in sails.

Q&A: Disable pubsub sails.js

I love short, concise blog posts. Let this be one of them!


After having had this question asked a couple of times, I decided it qualified for a dedicated blog post. This particular question has been asked on IRC, a while back on github and in a sense, as well on StackOverflow.

[10:29:53] RWOverdijk: do u know if there is a way to completely shut off the pubsub feature in blueprints?


In your project’s root, create a file called .sailsrc. Inside of this file, add the following:

Voila, you’ve disabled pubsub.

©SpoonX 2017