Auto reloading a Sails.js app on code changes?

Solution 1:

You have to use a watcher like forever, nodemon, or something else...

Example

  1. Install forever by running:

    sudo npm install -g forever

  2. Run it:

    forever -w start app.js


To avoid infinite restart because Sails writes into .tmp folder, you can create a .foreverignore file into your project directory and put this content inside:

**/.tmp/**
**/views/**
**/assets/**

See the issue on GitHub: Forever restarting because of /.tmp.

Solution 2:

You can use sails-hook-autoreload

Just lift your app as normal, and when you add / change / remove a model or controller file, all controllers and models will be reloaded without having to lower / relift the app.