aaP_48faraaz
I'd a similar situation where our React js app was gracefully shutting down. Problem is that currently panel doesn't have a mechanism to restart it automatically. And without this we cannot use it in production
Solution:
- Build using nodejs website creation option. and then identify the path for nodejs
- Create a systemd service file with target node js and your working directory with execution commands, port, and restart options.
- Enable the service and then start it, you will see the app running in localhost with port mentioned in the service file
- Then create a static php website and add Nginx reverse proxy to the above running app with the build folder as your project directory.
Sample Systemd file will look like this
[Unit]
Description=YourAppService
[Service]
WorkingDirectory=/www/wwwroot/path to your app directory.
ExecStart=/www/server/nodejs/v20.15.1/bin/node /www/server/nodejs/v20.15.1/bin/serve -s build -l 3000 (in your case this can be different we use serve module to serve the static file)
Restart=always
#Restart service after 10 seconds if the service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=your-app
User=www
Environment=NODE_ENV=production PORT=3000
[Install]
WantedBy=multi-user.target
This solved all our headache. and It never got down afterwards.