-1

I had set up an AWS EC2 which is running Ubuntu.

I want to run a Node.js server on it and use Dropbox to sync some files. I use ssh to access my EC2 like:

ssh -i xxx.pem ubuntu@ec2-xx-xx-xx-xx.ap-northeast-1.compute.amazonaws.com

Then I set up Node.js and Dropbox. (I set up Dropbox with the guide: Dropbox official page)

I run my Node.js with:

node app.js &

And it works. I can access my website with the IP of AWS EC2.

And I run Dropbox with:

~/.dropbox-dist/dropboxd &

It also works, and sync my files.

But after I close the terminal, the website is not accessible anymore. And Dropbox also stop running.

Is there any way to keep the processes running forever?

Community
  • 1
  • 1
Eric Sun
  • 65
  • 1
  • 8

1 Answers1

1

You started both of them in the background, but as part of your session. When your session ends, they die. Even using forever won't keep them alive when you logout.

Instead, you want to run them as a service. You can use a variety or tools for this, including pm2, systemd, or upstart. Most node Devs use pm2, but I've done it all three ways and they all work well.

Paul
  • 35,689
  • 11
  • 93
  • 122