Whenever I run the React app, I have to run manually by typing yarn build & yarn start. If I reboot the server, I should re-run manually again. Is there a better way of automatically running the web engine?
My idea is writing the command in /etc/rc.local file. But I am not sure if this is proper or not.
Thank you.
Use pm2: Advanced, production process manager for Node.js.
First install pm2 with
npm install --global pm2
and then you can start your app by
cd /path/to/app
pm2 start npm -- start
The pm2 will manage your React service.
If you want to auto run this on boot:
pm2 save # Save your process.
pm2 startup # Install auto start script.
Further information, you can find pm2 docs here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With