Giter VIP home page Giter VIP logo

supervisor_health's Introduction

Build Status

SupervisorHealth

This is the Supervisor Health module for Elixir applications. This can be used to provide a health endpoint in a web-based application or API.

Table of Contents generated with DocToc

Installation

The package can be installed as following:

  1. Add supervisor_health to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:supervisor_health, git: "https://github.com/meltwater/supervisor_health", tag: "0.1.1"}]
end
```
  1. Ensure supervisor_health is started before your application:
```elixir
def application do
  [applications: [:supervisor_health]]
end
```

Usage

In an application, e.g. a Plug API, you could use SupervisorHealth like this:

get "/_health" do
    case SupervisorHealth.health(MyApp.Supervisor) do
        {:ok, resp} -> send_resp(conn, 200, resp)
        {:error, resp} -> send_resp(conn, 500, resp)
    end
end

Responses

In general, the library will produce following 2 responses:

  • {:ok, response} if everything is OK
  • {:error, response} if any error occurred

The response contains information on any Supervisor child processes.

Example

Using curl on the Plug-based API mentioned above, a possible response could be:

$ curl http://localhost:4200/_health | jq .
{
  "internalProcesses": {
    "{:ranch_listener_sup, MyApp.Http.Router.HTTP}": {
      "status": "waiting",
      "stack_size": 9,
      "reductions": 175,
      "current_function": [
        "gen_server",
        "loop",
        6
      ]
    },
    "MyApp.Database": {
      "status": "waiting",
      "stack_size": 9,
      "reductions": 1136,
      "current_function": [
        "gen_server",
        "loop",
        6
      ]
    }
  },
  "health": "ok"
}

Contact

For questions, bug reports and feature requests do not hesitate to create an issue on github.

License

See License.

supervisor_health's People

Contributors

hgschmidtmw avatar otype avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.