Auto reloading a Sails.js app on code changes?

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.


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.


For example with nodemon to watch api and config directories

.nodemonignore contents

views/*
.tmp/*
.git/*

Run the command after creating .nodemonignore

$> nodemon -w api -w config

Example for supervisor to ignore 3 directories

$> supervisor -i .tmp,.git,views app.js