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.

gefragt vor 2 Jahren418 Aufrufe
1 Antwort
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

beantwortet vor 2 Jahren
  • Will try it out thanks !

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

    'nohup yourprocess &'

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen