JoeZ JoeZ - 25 days ago 12
Node.js Question

How to run app.js deployed on remote server from local bash?

I deployed my web app on GoDaddy. My web app is developed in Node.js. So, I need to run app.js. I can run app.js from my computer's bash command prompt. But if I shut down my laptop, then I can't see the web page, i.e. the app.js is down. How can I run app.js so that I don't need to worry about shutting down my laptop?

Answer

So if you're literally logged in to the server as a user of some kind, and in that terminal session you run something like node ./app.js to run your app, then when your session closes the app will also shut down, since you're running it as a user which then logs out (similar to how Word doesn't keep running a spell check when you hit spell check and then power down your machine).

What you need to do is configure your application to run as a service. The specific mechanism to do this will depend greatly on what kind of server you're running (Ubuntu, Centos, Windows, etc).

Most modern Linux distros come with systemd, for example, and that would be how I'd do it on them. There's a good tutorial on it here.

Comments