Appcelerator Blog

The Leading Resource for All Things Mobile

Quick tip: Auto restarting your Node.ACS apps

3 Flares 3 Flares ×

If you’ve been developing Node.ACS (or Node.JS) apps, you know that every time you make a change to any of your source files, you need to go to your Terminal to stop the process and restart it.

NodeMon is a Node.js tool that monitors your app folder and when it sees a change, it automatically restarts your app. This means that during your development process you’ll go from saving your changes, straight to testing them, skipping the step of stopping and restarting your server. NodeMon is designed to be used with Node.js but with a special flag you can get it to work with Node.ACS.

To install NodeMon, simply fetch it from NPM:

npm install -g nodemon

Then go to your Node.ACS project folder and run your app through NodeMon like this:

nodemon --exec "acs run"

Your Terminal/Console window will let you know that you’ve successfully started your app through NodeMon:

14 Oct 10:52:50 - [nodemon] v0.7.8
14 Oct 10:52:50 - [nodemon] to restart at any time, enter `rs`
14 Oct 10:52:50 - [nodemon] watching: /Users/ralcocer/nodeacs/lilacs
14 Oct 10:52:50 - [nodemon] starting `acs run app.js`

ACS: Appcelerator Cloud Services Command-Line Interface, version 1.0.7
Copyright (c) 2012-2013, Appcelerator, Inc.  All Rights Reserved.

[INFO]  No dependencies detected
[INFO]  socket.io started
[INFO]  ACS started on port 8080

From this moment on, any changes on files within this app will cause Node.ACS to be restarted. Go ahead, try it!

NodeMon also provides a flag to specify extensions to monitor. To only restart on changes to js and ejs files, you’d run it like this:

nodemon --exec "acs run" --ext ".js|.ejs"
There are some other useful settings, so make sure you check the documentation. Hope you find this useful, as it greatly improves your development workflow.
3 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 3 Email -- 3 Flares ×

1 Comment

Comments are closed.

Sign up for updates!

Become a mobile leader. Take the first step to scale mobile innovation throughout your enterprise.
Get in touch
computer and tablet showing Appcelerator software
Start free, grow from there.
3 Flares Twitter 0 Facebook 0 Google+ 0 LinkedIn 3 Email -- 3 Flares ×