Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto reloading a Sails.js app on code changes?

Currently is seems that for any code change in a sails.js app you have to manually stop the sails server and run sails lift again before you can see the changes.

I was wondering if there is any way when running in development mode to automatically restart the sails server when it detects a code change?

like image 977
subblue Avatar asked Sep 08 '13 19:09

subblue


People also ask

Is sails JS popular?

Sails is the most popular MVC framework for Node. js, designed to emulate the familiar MVC pattern of frameworks like Ruby on Rails, but with support for the requirements of modern apps: data-driven APIs with a scalable, service-oriented architecture.

What is waterline in sails JS?

Waterline: SQL/noSQL Data Mapper (ORM/ODM) Sails comes installed with a powerful ORM/ODM called Waterline, a datastore-agnostic tool that dramatically simplifies interaction with one or more databases.

How does sails JS work?

Sails is built on Node. js, a popular, lightweight server-side technology that allows developers to write blazing fast, scalable network appliations in JavaScript. Sails uses Express for handling HTTP requests, and wraps socket.io for managing WebSockets.

How do I update the version of sails?

Upgrading an existing app using the automated tool To get started, we recommend using the Sails 1.0 upgrade tool, which will help with some of the most common migration tasks. To use the tool, first install Sails 1.0 globally with npm install -g sails@^1.0. 0 and then run sails upgrade .


1 Answers

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.

like image 188
Sandro Munda Avatar answered Oct 19 '22 22:10

Sandro Munda