{
  "apps": [
    {
      "name": "api",
      "script": "api.js",
      "exec_mode": "cluster",
      "wait_ready": true,
      "instances": "max",
      "env_production": {
        "NODE_ENV": "production"
      }
    },
    {
      "name": "proxy",
      "script": "proxy.js",
      "exec_mode": "cluster",
      "wait_ready": true,
      "instances": "max",
      "env_production": {
        "NODE_ENV": "production"
      }
    }
  ],
  "deploy": {
    "production": {
      "user": "deploy",
      "host": [{% for host in groups['api'] %}"{{ hostvars[host].ansible_host }}"{% if not loop.last %}, {% endif %}{% endfor %}],
      "ref": "origin/master",
      "repo": "{{ lookup('env', 'GITHUB_REPO') }}",
      "path": "/var/www/production",
      "pre-deploy": "git reset --hard",
      "post-deploy": "npm install && NODE_ENV=production npm start build && pm2 startOrGracefulReload ecosystem-api.json --env production --update-env"
    }
  }
}
