Question

I'm messing around with a fork of foaas (on github), a little service built with CoffeeScript and Node. I've got it running on an ec2 instance and, as a starting point, have just switched some of the hard-coded string values around in server.coffee.

After making my changes I run the server again with:

coffee server.coffee

The problem is that nothing changes! The strings I have swapped around still reflect their old values. Clearly I am missing some kind of build tool that's in place here. The dir tree looks like so:

├── lib
│   └── operations.coffee
├── LICENSE
├── package.json
├── Procfile
├── public
│   ├── googlead0e382f658e6d8e.html
│   └── index.html
├── README.md
└── server.coffee

From what I've gathered, I need a tool to read the Procfile in order to compile the coffeescript files into js and run them, all-at-once. That's quite an abstract thing to google and my attempts have proved fruitless. How do I get my changes reflected?

I haven't used Node much and haven't used CoffeeScript or Express at all but I have read their related documentation so mostly know what's happening in the code.

Was it helpful?

Solution

Expanded from the comment which solved the issue:

On every change, you can restart the server using Supervisor


As an additional step, for building your coffee files into js you can use grunt to automate the compilation, and watch changes to the coffee file too.

OTHER TIPS

You'll need foreman to start your Procfile -- you can use node-dev to run your server (which automatically restarts upon changes).

npm install node-dev --save

And to avoid Grunt headaches, you could also specify compile watchers in your Procfile:

web: ./node_modules/node-dev/bin/node-dev server.coffee
coffee: ./node_modules/.bin/coffee --watch --compile --output ./ lib

And to run your Procfile: foreman start -f Procfile

See here for the coffee-script command line usage

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top