DEV Community

See Kian Shim
See Kian Shim

Posted on

Keep Vite 4.0.4 server alive always

I'm trying to do development in react-admin with vite. I've done something and deployed to the ubuntu server for testing purpose. In the root folder of react-admin project under ubuntu, I'm triggering the Vite server with "yarn dev". Everything is running smoothly without any issue, the only annoying part is the project url was unreachable after 2 hours. I will need to trigger the Vite server with "yarn dev" again. Anyone have any idea to keep the Vite server keep alive without disconnect?

Top comments (2)

Collapse
 
kristories profile image
Wahyu Kristianto • Edited

To keep the Vite server running continuously, you can use a process manager like PM2 :

  • Install PM2:
  npm install pm2 -g
Enter fullscreen mode Exit fullscreen mode
  • Start the Vite server with PM2:
  pm2 start yarn --name "vite-server" -- dev
Enter fullscreen mode Exit fullscreen mode
  • Save the PM2 process list:
  pm2 save
Enter fullscreen mode Exit fullscreen mode

With these steps, PM2 will keep the Vite server running in the background and restart it if it crashes or if the server restarts.

Collapse
 
kristories profile image
Wahyu Kristianto

Btw, use the hashtag #help for posts that need help

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git