1

When I close putty after running 'serve -s build' session stops and my React app stops working

Hello! I created a small React application using create-react-app. I want to deploy this app on Linux server, so I use the command npm run build, which creates 'build' folder. Then I move 'build' folder to server and use the command serve -s build. The app works fine, but there's the problem - when I close putty (which I use to connect to my server) session closes and React app stops. I tried to use the command like this serve -s build &, but that doesn't help and every time I close the session the app stops

Could you please help and clarify what is the right way to deploy React app on server? How to make it work even when I close putty?

Thanks for your time

aquam
  • 11
  • 2
  • Does this answer your question? [Run a shell script and immediately background it, however keep the ability to inspect its output](https://stackoverflow.com/questions/44222883/run-a-shell-script-and-immediately-background-it-however-keep-the-ability-to-in) – Konrad Jul 24 '23 at 11:46
  • Thank you, I tried using nohup serve -s build & and it doesn't help. So I think it is not a duplicate – aquam Jul 24 '23 at 12:15

1 Answers1

0

Thanks to the comment by Konrad I finally realized that the problem was not with the React command, but in running processes in background mode. Using serve -s build & and nohup serve -s build > f1.txt & didn't help, but when I started searching for the right terms I found this answer here.
This link helped a lot as well.

So after reading the articles my steps were:

nohup serve -s build > f1.txt &
jobs -l
*the id of my process was 1*
disown %1
Kristian
  • 2,456
  • 8
  • 23
  • 23
aquam
  • 11
  • 2