message: use cluster for server so it can handle more
diff: @@ -2,19 +2,19 @@ const argv = require('minimist')(process.argv);
  const fs = require('fs');
  const path = require('path');
  const express = require('express');
  +const cluster = require('cluster');
  const { createBundleRenderer } = require('vue-server-renderer');
  -const isProd = process.env.NODE_ENV === 'production';
  -
  -const serverBuildPath = isProd ? '../../build/prod-server/' : '../build/dev-server/';
  -const clientBuildPath = isProd ? '../../build/prod/' : '../build/dev/';
  -
  function resolve(file) {
  return path.resolve(__dirname, file);
  }
  +const numCPUs = require('os').cpus().length;
  +const isProd = process.env.NODE_ENV === 'production';
  const section = argv.section || 'app';
  -const server = express();
  +const serverBuildPath = isProd ? '../../build/prod-server/' : '../build/dev-server/';
  +const clientBuildPath = isProd ? '../../build/prod/' : '../build/dev/';
  +
  const serverBundle = require(path.join(
  serverBuildPath,
  'vue-ssr-server-bundle-' + section + '.json'
  @@ -24,6 +24,22 @@ const clientManifest = require(path.join(
  'vue-ssr-client-manifest-' + section + '.json'
  ));
  +if (cluster.isMaster) {
  + console.log(`Master ${process.pid} is running`);
  +
  + // Fork workers.
  + for (let i = 0; i < numCPUs; i++) {
  + cluster.fork();
  + }
  +
  + cluster.on('exit', (worker, code, signal) => {
  + console.log(`worker ${worker.process.pid} died`);
  + cluster.fork();
  + });
  +} else {
  + console.log(`Worker ${process.pid} started`);
  +
  + const server = express();
  const renderer = createBundleRenderer(serverBundle, {
  runInNewContext: true,
  template: fs.readFileSync(resolve('./index-ssr.html'), 'utf-8'),
  @@ -68,3 +84,4 @@ const port = 3501;
  server.listen(port, () => {
  console.log(`server started at localhost:${port}`);
  });
  +}
  