Server process run through command do not persist in my Amazon Lightsail Instance

0

I created an Amazon Lightsail Instance of 512MB RAM,

I have got all my production server files installed on my Amazon Lightsail Instance. Then I connected to the instance via SSH. Then I ran my database command in the background via the browser SSH window:

mongod --dbpath=data &

Then I ran my server command in the background:

next start -H <private_ip> -p <port>

Then I closed the browser ssh window. Then, after some time I found that the server was not able to be reached via the url. It was working when I had the ssh window open.

I opened the ssh window again, and did ps to see if the processes were still running. I found that both the database process and the server process were closed.

I want them to persist forever, i.e. the processes shouldn't close because I want to use my website at any time right.

已提问 2 年前418 查看次数
1 回答
1

Try this, after you start the process:

  1. ctrl+ z
  2. bg
  3. disown -h or disown -a Basically running the process as background.

There are options tmux, nohup, screen, byobu. PS: I am a beginner and I got this info after a bit of googling. I hope it helps. Please ignore if it doesn't or if you know this already

已回答 2 年前
  • Will try it out thanks !

  • Alternatively, use "&" to disconnect the process from the login session.

    'nohup yourprocess &'

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则