title: Prevent multiple Node Express instances
body: <p>This is a Windows server with IIS and IISNODE (if that is relevant).</p>
  
  <p>I have the following code in app.ts (simplified)</p>
  
  <pre><code>import * as express from "express";
  import log from "../util/log";
  
  class App {
      public express: express.Application;
  
      constructor() {
          this.express = express();
          log.default.info("starting app");
          this.middleware();
      }
  
      private middleware(): void {
          log.default.info("starting middleware");
          this.express.use((req: IRequest, res: express.Response, next: express.NextFunction) =&gt; {
              this.getAllClientConfigurations(req, res, next);
          });
  
      etc.....
  </code></pre>
  
  <p>When restarting the site in IIS and then hitting it with a request it generates two records of "starting app" in the log file generated by the log script</p>
  
  <p>This causes the middleware() function to be called twice. Inside the middleware function I call another function that sets up some client variables and start up some Cron services which are essential that are running only once.</p>
  
  <p>How can I make sure everything just runs one time?</p>