Search code examples
javascriptnode.jsexpressbackendvercel

Any way to restart a nodejs application hosted on vercel?


I've a nodejs/express application hosted on vercel. The way I've set it up is that when the server starts it connects to the database (mongo atlas) and checks if there's a user by the username of admin or not if it's not there then it will create one.

I had to delete my data from the database. And now I need to restart the nodejs server so that it can automatically create the user. Which is required to login to the application.

any idea how to restart the server. So that it can reconnect to the mongodb and after that it creates the required user.

I've redeply the app multiple times but that doesn't seem to restart it as no new user was created. This is my vercel.json file

{
   "version": 2,
   "name": "mf-backend",
   "builds": [
      { "src": "server.js", "use": "@vercel/node" }
   ],
   "routes": [
      { "src": "/(.*)", "dest": "/server.js" }
   ]
}

Solution

    1. Go to vercel page.

    2. Click the project you created.

    3. Click the deployments section on the left-top menu.

      enter image description here

    4. There will be deployments. If you want to re-deploy your last deploy, click the settings icon then select redeploy selection on the dropdown menu.

      enter image description here

    5. Then the project will be redeployed according to your last deployment.

    If you want to examine the deployment logs, you can examine logs on "View Build Logs" and "View Function Logs". They are on the project's main page.