ExOps

Provides standardized support for obtaining environment, version, and heartbeat information in JSON format

Table of Contentsgenerated with DocToc

Installation

def deps do
  [{:ex_ops, "~> 2.2.0"}]
end

Default settings

build_info_regex: ~r/:\s([\w|-]+)/,
deploy_info_regex: ~r/:\s\"(.+)\"\n/,
info_files: %{
  build_info_file: %{
    type: :path,
    path: "../BUILD-INFO"
  },
  deploy_info_file: %{
    type: :path,
    path: "../DEPLOY-INFO",
  },
  previous_build_info_file: %{
    type: :path,
    path: "../PREVIOUS-BUILD-INFO"
  },
  previous_deploy_info_file: %{
    type: :path,
    path: "../PREVIOUS-DEPLOY-INFO"
  }
}

Overide via config.exs

For example, to load the files from your app's priv directory you would do something like:

config :ex_ops,
  build_info_regex: <CUSTOM_REGEX>,
  deploy_info_regex: <CUSTOM_REGEX>,
  info_files: %{
    build_info_file: %{
      type: :priv_dir,
      application: :your_app,
      path: "../BUILD-INFO"
    },
    deploy_info_file: %{
      type: :priv_dir,
      application: :your_app,
      path: "../DEPLOY-INFO",
    },
    previous_build_info_file: %{
      type: :priv_dir,
      application: :your_app,
      path: "../PREVIOUS-BUILD-INFO"
    },
    previous_deploy_info_file: %{
      type: :priv_dir,
      application: :your_app,
      path: "../PREVIOUS-DEPLOY-INFO"
    }
  }

BUILD-INFO format

---
version: 20160613-100-09d5671
build_number: 100
git_commit: 09d5671224b03969c629d9265417bc82c4aac48f

DEPLOY-INFO format

---
deploy_date: "2016-12-06 18:04:27"

Configure routes

Add following to your router.ex, scope defaults to /ops but can be set to anything you like

scope "/ops" do
  get "/:path", ExOps.Plug, []
end

Routes

/ops/version
{
  "host": "localhost",
  "deployment": {
    "tag": "20161129-23-c736197",
    "short_commit_sha": "c736197",
    "previous": {
      "tag": "20161129-22-d7d5369",
      "short_commit_sha": "d7d5369",
      "date": "2016-12-06 17:59:15",
      "commit_sha": "d7d5369a24870ac807da79d4e67a78c8e0ff25b",
      "build_number": "22"
    },
    "date": "2016-12-06 18:04:27",
    "commit_sha": "c7361976bdcb5bdf2cf4fd31b027ddc8dc5e598b",
    "build_number": "23"
  }
}
/ops/heartbeat
{
  "status": 200,
  "message": "Ok"
}
/ops/env

Running the tests

Test include

Contributing

License

MIT