Check out a free preview of the full Full Stack for Front End Engineers course:
The "Keeping an app running" Lesson is part of the full, Full Stack for Front End Engineers course featured in this preview video. Here's what you'd learn in this lesson:

To keep from having to start and stop the web server repeatedly, Jem demonstrates a process manager called Forever that keeps the process running indefinitely.

Get Unlimited Access Now

Transcript from the "Keeping an app running" Lesson

[00:00:00]
>> Jem Young: So how do we keep our app up and running? Currently we have to run note app every time and kill it then make a change, run GULP, make a change, and then do that over and over. We don't wanna do that. There's better ways to do that.

[00:00:09] We're engineers. A good tenant of a good engineers is they're lazy. They do not wanna repeat themselves over and over again that's what we have scripts. That's true ask any engineers you've been around awhile they're very, very lazy, as they should be. So we're gonna use Forever. Forever is a process manager and it's gonna keep our app up and running indefinitely until we kill it.

[00:00:30] Or there's some sort of error that causes it to error out where it can't restart but it'll keep it up, so that way we run forever, and it's just gonna run to the background and we don't have to worry about it anymore. It's just always gonna be running.

[00:00:41] There's also Strong Loop Process Manager, or PM2. PM2's pretty popular. I like Forever because it's just JavaScripts, and by default I generally use the JavaScript packages more. But, PM2's also great. Strong Loop's pretty solid too. So, let's run Forever. Let's make sure we're in our app directory. Then, "npm i -g forever"

[00:01:09]
>> Jem Young: And I will go ahead and do it as well.
>> Jem Young: And those optional dependencies are fine, it won't affect anything. So now, if I say forever start app.js. Instead of saying node.js, we can start app, because it defaults to a node system. Hit Enter and now our app's up and running.

[00:01:52]
>> Jem Young: But we can keep using the command line as we will and let's just double check that the app is working. So go to gem.party and it's still up and running. Yes I didn't add to my HTML cuz I am a lazy, lazy person, but I can do HTML, trust me.

[00:02:08] So our app is up and running. And it's up and running in the background now. It's gonna stay up and running until we stop it. So to stop a Forever script, we're just gonna say forever stopall. And that's gonna stop our node process. Refresh, it's a bad gateway cuz node is no longer running.

[00:02:28] That's the great thing about Forever, once you get it up and running, it just runs forever, and you don't have to worry about it.