{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "definitions": {
    "app": {
      "type": "object",
      "properties": {
        "script": {
          "type": "string",
          "description": "Path of the script to launch"
        },
        "name": {
          "type": "string",
          "description": "Process name in the process list. Defaults to script filename without the extension (app for app.js)"
        },
        "cwd": {
          "type": "string",
          "description": "Current working directory to start the process with. Defaults to CWD of the current environment (from your shell)"
        },
        "args": {
          "description": "Arguments to pass to the script",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "interpreter": {
          "type": "string",
          "description": "Interpreter absolute path. Defaults to node"
        },
        "interpreter_args": {
          "description": "Options to pass to the interpreter",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "error_file": {
          "type": "string",
          "description": "File path for stderr (each line is appended to this file)",
          "default": "~/.pm2/logs/<app_name>-error.err"
        },
        "out_file": {
          "type": "string",
          "description": "File path for stdout (each line is appended to this file)",
          "default": "~/.pm2/logs/<app_name>-out.log"
        },
        "combine_logs": {
          "type": "boolean",
          "description": "If set to true, avoid to suffix logs file with the process id",
          "default": "/dev/null"
        },
        "merge_logs": {
          "type": "boolean",
          "description": "Alias to combine_logs"
        },
        "pid_file": {
          "type": "string",
          "description": "File path where the pid of the started process is written by pm2. Defaults to ~/.pm2/pids/app_name-id.pid"
        },
        "disable_logs": {
          "type": "boolean",
          "description": "Disable all logs storage"
        },
        "log_type": {
          "type": "string",
          "description": "Define a specific log output type",
          "enum": ["json"]
        },
        "log_date_format": {
          "type": "string",
          "description": "Format for log timestamps in moment.js format (eg YYYY-MM-DD HH:mm Z)"
        },
        "env": {
          "type": "object",
          "description": "Specify environment variables to be injected",
          "additionalProperties": {
            "type": "string"
          }
        },
        "env_": {
          "type": "object",
          "description": "Specify environment variables to be injected (when passing --env)",
          "additionalProperties": {
            "type": "string"
          }
        },
        "max_memory_restart": {
          "type": "number",
          "description": "Restart the app if an amount of memory is exceeded (format: /0-9?/ K for KB, 'M' for MB, 'G' for GB, default to B)"
        },
        "restart_delay": {
          "type": "number",
          "description": "Time in ms to wait before restarting a crashing app"
        },
        "source_map_support": {
          "type": "boolean",
          "description": "Enable or disable the source map support",
          "default": true
        },
        "disable_source_map_support": {
          "type": "boolean",
          "description": "Enable or disable the source map support"
        },
        "wait_ready": {
          "type": "boolean",
          "description": "Make the process wait for a process.send('ready')"
        },
        "instances": {
          "type": "number",
          "description": "Number of instances to be started in cluster mode",
          "default": 1
        },
        "kill_timeout": {
          "type": "number",
          "description": "Time in ms before sending the final SIGKILL signal after SIGINT",
          "default": 1600
        },
        "listen_timeout": {
          "type": "number",
          "description": "Time in ms before forcing a reload if app is still not listening/has still not sent ready"
        },
        "cron_restart": {
          "type": "string",
          "description": "A cron pattern to restart your app"
        },
        "vizion": {
          "type": "boolean",
          "description": "Enable or disable the versioning metadatas (vizion library)",
          "default": true
        },
        "autorestart": {
          "type": "boolean",
          "description": "Enable or disable auto restart after process failure",
          "default": true
        },
        "watch": {
          "type": "boolean",
          "description": "Enable or disable the watch mode"
        },
        "ignore_watch": {
          "description": "List of paths to ignore (regex)",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "watch_options": {
          "type": "object",
          "description": "Object that will be used as an options with chokidar (refer to chokidar documentation)"
        },
        "min_uptime": {
          "type": "number",
          "description": "Minimum uptime of the app to be considered started (format is /[0-9]+(h|m|s)?/, for hours, minutes, seconds, default to ms)",
          "default": 1000
        },
        "max_restarts": {
          "type": "number",
          "description": "Number of times a script is restarted when it exits in less than min_uptime",
          "default": 16
        },
        "exec_mode": {
          "type": "string",
          "description": "Set the execution mode",
          "enum": ["fork", "cluster"],
          "default": "fork"
        },
        "force": {
          "type": "boolean",
          "description": "Start a script even if it is already running (only the script path is considered)"
        },
        "append_env_to_name": {
          "type": "boolean",
          "description": "Append the environment name to the app name"
        },
        "post_update": {
          "type": "array",
          "description": "List of commands executed after a pull/upgrade operation performed from Keymetrics dashboard",
          "items": {
            "type": "string"
          }
        },
        "shutdown_with_message": {
          "type": "boolean",
          "description": "Shutdown an application with process.send('shutdown') instead of process.kill(pid, SIGINT)"
        },
        "trace": {
          "type": "boolean",
          "description": "Enable or disable the transaction tracing"
        },
        "disable_trace": {
          "type": "boolean",
          "description": "Enable or disable the transaction tracing",
          "default": true
        },
        "increment_var": {
          "type": "string",
          "description": "Specify the name of an environment variable to inject which increments for each cluster"
        },
        "instance_var": {
          "type": "string",
          "description": "Rename the NODE_APP_INSTANCE environment variable. Defaults to NODE_APP_INSTANCE"
        },
        "filter_env": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Excludes global variables starting with \"REACT_\" and will not allow their penetration into the cluster"
        },
        "pmx": {
          "type": "boolean",
          "description": "Enable or disable apm wrapping",
          "default": true
        },
        "automation": {
          "type": "boolean",
          "description": "Enable or disable apm wrapping",
          "default": true
        },
        "treekill": {
          "type": "boolean",
          "description": "Only kill the main process, not detached children",
          "default": true
        },
        "port": {
          "type": "number",
          "description": "Shortcut to inject a PORT environment variable"
        },
        "uid": {
          "type": "string",
          "description": "Set user id. Defaults to current user uid"
        },
        "gid": {
          "type": "string",
          "description": "Set group id. Defaults to current user gid"
        }
      },
      "patternProperties": {
        "^env_\\S+$": {
          "type": "object",
          "description": "Specify environment variables to be injected when using --env",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "required": ["script"]
    },
    "deploymentEnvironment": {
      "type": "object",
      "properties": {
        "key": {
          "type": "string",
          "description": "SSH key path. Defaults to $HOME/.ssh"
        },
        "user": {
          "type": "string",
          "description": "SSH user"
        },
        "host": {
          "description": "SSH host",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "ssh_options": {
          "description": "SSH options with no command-line flag, see 'man ssh'",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        },
        "ref": {
          "type": "string",
          "description": "GIT remote/branch"
        },
        "repo": {
          "type": "string",
          "description": "GIT remote"
        },
        "path": {
          "type": "string",
          "description": "path in the server"
        },
        "pre-setup": {
          "type": "string",
          "description": "Pre-setup command or path to a script on your local machine"
        },
        "post-setup": {
          "type": "string",
          "description": "Post-setup commands or path to a script on the host machine"
        },
        "pre-deploy-local": {
          "type": "string",
          "description": "pre-deploy action"
        },
        "post-deploy": {
          "type": "string",
          "description": "post-deploy action"
        }
      }
    }
  },
  "id": "https://json.schemastore.org/pm2-ecosystem.json",
  "properties": {
    "apps": {
      "type": "array",
      "description": "The apps property is an array of object where each object contains the configuration for each process.",
      "items": {
        "$ref": "#/definitions/app"
      }
    },
    "deploy": {
      "type": "object",
      "description": "The deploy property is an object where each of its properties is an object which defines a deployment environment.",
      "properties": {
        "production": {
          "$ref": "#/definitions/deploymentEnvironment"
        },
        "staging": {
          "$ref": "#/definitions/deploymentEnvironment"
        },
        "development": {
          "$ref": "#/definitions/deploymentEnvironment"
        }
      }
    }
  },
  "title": "PM2 ecosystem config file",
  "type": "object"
}
