How do I enable the strapi app after restarting the server?

I have an ubuntu 18.04 server , after restarting the server, the site does not work and 502 error. The site is powered by strapi.
How do I enable it after the server is restarted?

the easiest way is to use pm2:

For Startup script:

You should also learn a little bit about ubuntu, systemd and nodejs.
But there are plenty of options out there.

Hello! Thanks for the answer! I don’t know much about nodejs and strapi yet . I have this file in the root of the site folder , its name ecosystem.config.js

My server support says that you need to run node js for the server to work, how do I run rafter? using this file? or connect backend and frontend?
Sorry for my english)

I’m doing an app launch pm2 start ecosystem.config.js , the site is enabled but there are many errors.

Error: {"graphQLErrors":[],"networkError":{},"message":"Network error: Failed to fetch"}

and the admin panel doesn’t work.

Can you please provide the pm2 logs from the application? The default location should be in ~/.pm2/logs

As a side point I don’t generally recommend using the ecosystem file to store environment variables, you should instead use the .env file

problel resolved

pm2 start ecosystem.config.js --env production