This is probably only applicable to beginners as I can only assume experienced users have already had this issue and quickly did what I have and found the solution. But for those of you who haven’t then make sure to do this when developing your next Sails application.
Note: I'm assuming you already have Sails installed
Install forever. (Other packages are available for this, but this is what I use)
[sudo] npm install forever -g
Create your new Sails.js application wherever you want
sails new awesomeApplication cd awesomeApplication
Now you want to add a file called .foreverignore
“`nano .foreverignore
Add the following lines to the file
**/.tmp/**
**/views/**
**/assets/**
If you have Sails installed globally then you will have to run the following command, which will add Sails to your application.
npm install sails
Now when you lift your application instead of using
sails lift
you use…
forever -w start app.js # -w to watch for file changes!
Now you can enjoy coding your application and let Forever handle restarting the server when changes are made.
But wait now forever launches it in the background and I can’t see my console.logs…
No problem!, in your terminal find your .forever location generally in your Home folder and run the following
See update for a better way than this…
List running apps to get log file name
forever list
ls #list the files to find the log file 0P9R.log 9UBR.log KqgI.log config.json ehQC.log pids qvyg.log sock
tail -f KqgI.log
To stop your application just run
forever stop app.js
Update
Thanks to zieglar for the tip
Instead of using tail command you can just use forever to stream it out with…
forever logs app.js -f
If you have multiple applications running which are all called app.js you will have to use the index so just grab that from the list (it will be in square brackets) by using
forever list
Start the log using the index
forever logs 2 app.js -f