Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Forever with Ember-CLI

I've set up a website using Ember-CLI and it is now ready for production, so we're looking for a way to keep it running permanently.

Right now we're using $ ember serve --port 80

but obviously this only works whilst we're logged in. I've used Forever before to keep a node app running but am not sure how to make this work with Ember CLI, as the 'ember serve' command obviously does more than just running app.js?

Any input would be appreciated!

like image 230
James Gupta Avatar asked Aug 10 '14 10:08

James Gupta


1 Answers

Ember-CLI apps are NOT node apps, they are Browser apps, so you don't need anything special to serve them. To keep and Ember-CLI app running permanently, I suggest doing:

ember build --environment=production

This will perform the necessary build steps so that the code works in browsers (e.g, transpiling ES6 modules) and put the code in the build folder. It will also minify JS files and fingerprint all resources (this only happens when the environment is production).

All you have to to then is put the files inside the dist/ folder on a Web Server.

I suggest Apache or Nginx, but anything will work.

Edit

As Omair Vaiyani pointed out, this might not work in some servers because Ember-CLI uses the locationType: 'auto' which defaults to 'history'. For that to work, you have to configure your SERVER to serve the ember app from all routes.

What I do, and server me well because I don't have control over the server, is to simply change the locationType to 'hash', which will generate URLs with hashes (http://myemberapp/#/myroute/myid) and will work with any server. Just edit the environment.js file accordingly:

module.exports = function(environment) {
   var ENV = {
      /* other stuf ... */
      locationType: 'hash',
      /* other stuf ... */
   },
   /* other stuff */

```

like image 83
Paulo Schreiner Avatar answered Oct 09 '22 11:10

Paulo Schreiner