0 throngでwebサーバーをクラスタリング #nodejs #express #heroku みんなに公開

HerokuでNode.jsのアプリをExpressで作って、クラスタリングを試すのにthrongを使ったのでwebサーバーの起動方法をメモ

const throng = require('throng');

// 中略

throng({
  workers: config.webConcurrency,
  lifetime: Infinity,
  master: () => {
    console.log('Started master');
  },
  start: (id) => {
    app.listen(config.port, () => {
      console.log(`Started worker ${id} on port: ${config.port}`);
    });
    process.on('SIGTERM', () => {
      console.log(`Worker ${id} exiting...`);
      process.exit();
    });
  },
});

参考: Optimizing Node.js Application Concurrency | Heroku Dev Center

0

メモを他の人に見せる

このメモを見せたい人に、このURL(今開いているページのURLです)を教えてあげてください

コメント(0)

  • someone

  • someone