I've successfully just created a new droplet on Digital Ocean using their MEAN on Ubuntu 14.04 image. I can run my app from the terminal using 'grunt serve' and then view it in the browser at "ip_address:3000". But I still don't understand how I can serve it permanently, by which I mean, keep the app running even after I close my terminal. I've heard of the tool "Forever", but I don't really understand it. Do I even need it or is there another simpler way?
-
2If you don't understand [`forever`](https://github.com/nodejitsu/forever), keep reading the documentation and experimenting with it. There's not much to it and their examples are pretty straightforward. – tadman Jul 01 '14 at 17:34
-
2seriously, it doesn't get much easier than forever: "npm install forever -g" then "forever start app.js" then "forever list" to see that it is running and where its log file is. Do tail -f log_file_path to see the latest additions to the log file live. – Catalyst Jul 01 '14 at 18:30
-
OK, I feel like a real dufus now. I was sure I tried "forever start app.js" and nothing happened, must have done something wrong. Thanks for helping me out! – Noahdecoco Jul 02 '14 at 02:08
-
Although, even forever will not run forever like that, it will only run until the server restart. You also want to add the app into "services" to be run at startup. Something like this: https://www.exratione.com/2013/02/nodejs-and-forever-as-a-service-simple-upstart-and-init-scripts-for-ubuntu/ – Zlatko Jul 02 '14 at 20:54
2 Answers
On the command line do:
$ export NODE_ENV=production
will setup production environmental
$ grunt build
will create necessary .min.js and min.css
$ forever start server.js
will load the server with forever, that its a package thats makes sure the node server will restart if an error and will log.

- 2,740
- 5
- 28
- 47

- 701
- 8
- 11
I don't know digital ocean at all, but I can tell you that you are looking for a webserver such as nginx.
The way you are running your server is really just for development purposes. That's why when you close your terminal the application stops execution.
Setting up servers can be its own large task. This is a nodejs nginx example Node.js + Nginx - What now?
You may have to Google for some more specific examples or tutorials on how to do it with digital ocean.
EDIT: you can also run a background process that will not stop executing when you exit the shell session. http://linuxtidbits.wordpress.com/2008/02/01/background-a-process/

- 1
- 1

- 486
- 2
- 11
- 16
-
He is using Mean inside a machine with node, no nginx here, its a pure mean/node machine. – Kiko Seijo Oct 04 '16 at 15:04