In this guide, we build the application locally and serve it though a PM2 config file with the cluster mode activated. Cluster mode will prevent downtime by allowing applications to be scaled across multiple CPUs.
Make sure you have pm2 installed on your server. If not, simply globally install it from yarn or npm.
module.exports = {
{
name: 'NuxtAppName',
instances: 'max', // Or a number of instances
args: 'start'
}
}
Now build your app with npm run build
.
And serve it with pm2 start
.
Your Nuxt.js application is now serving!
This solution guarantees no downtime for your application on this server. (You should also prevent server failure through redundancy or high availability cloud solutions.)