for making screen capture image of site
function makeScreenCap(zsId, url, req) {
  const zlSite = app.models.zlSite;

  // make screen capture (skip if is screencap request during screencap building)
  if (!req.get('X-Phantom-Js')) {
    let siteScreenCap = '';
    let cap = spawn(`${path.join(__dirname, "helpers/phantomjs")}`, [
      '--ignore-ssl-errors=true',
      path.join(__dirname, "helpers/siteScreenCap.js"),
      url,
      req.accessToken.id
    ]);

    cap.stdout.on('data', data => {
      siteScreenCap += data;
    });

    cap.on('close', (code) => {
      if (0 == code) {
        // screencap successful
        app.locals.cdn.upload(
          'site',
          zsId,
          'screenCap.png',
          new Buffer(siteScreenCap, 'base64'),
          {ContentType: 'image/png'},
          (err, data) => {
            if (err) console.error(err);

            if (!err && data) {
              let screenCap = `${data.url}?v=${new Date().valueOf()}`;
              // push image url to all current users who can edit the site
              _.delay(()=> {
                app.io.in(`authSite-${zsId}`).emit(events.SCREEN_CAP_UPDATED, zsId, screenCap)
              }, 3000);

              // save image url to db
              zlSite.findById(zsId, (err, site) => {
                if (site) {
                  let zsInternalConfig = Object.assign(
                    {},
                    site.zsInternalConfig,
                    {ScreenCap: screenCap}
                  );
                  site.updateAttribute('zsInternalConfig', zsInternalConfig);
                }
              })
            }
          }
        );
      }
      else {
        console.error(`Error: ${siteScreenCap}`);
      }
    });
  }
}