Coder Social home page Coder Social logo

supervisor3's Introduction

Extended Erlang/OTP supervisor

This file is a copy of supervisor.erl from the R16B Erlang/OTP distribution, with the following modifications:

  1. The module name is supervisor2.

  2. A find_child/2 utility function has been added.

  3. Added an 'intrinsic' restart type. Like the transient type, this type means the child should only be restarted if the child exits abnormally. Unlike the transient type, if the child exits normally, the supervisor itself also exits normally. If the child is a supervisor and it exits normally (i.e. with reason of 'shutdown') then the child's parent also exits normally.

  4. Child specifications can contain, as the restart type, a tuple {permanent, Delay} | {transient, Delay} | {intrinsic, Delay} where Delay >= 0 (see point (4) below for intrinsic). The delay, in seconds, indicates what should happen if a child, upon being restarted, exceeds the MaxT and MaxR parameters. Thus, if a child exits, it is restarted as normal. If it exits sufficiently quickly and often to exceed the boundaries set by the MaxT and MaxR parameters, and a Delay is specified, then rather than stopping the supervisor, the supervisor instead continues and tries to start up the child again, Delay seconds later.
    Note that if a child is delay-restarted this will reset the count of restarts towrds MaxR and MaxT. This matters if MaxT > Delay, since otherwise we would fail to restart after the delay.
    Sometimes, you may wish for a transient or intrinsic child to exit abnormally so that it gets restarted, but still log nothing. gen_server will log any exit reason other than 'normal', 'shutdown' or {'shutdown', _}. Thus the exit reason of {'shutdown', 'restart'} is interpreted to mean you wish the child to be restarted according to the delay parameters, but gen_server will not log the error. Thus from gen_server's perspective it's a normal exit, whilst from supervisor's perspective, it's an abnormal exit.

  5. Normal, and {shutdown, _} exit reasons are all treated the same (i.e. are regarded as normal exits).

  6. Rename the module to supervisor3.

  7. Introduce post_init callback. If Callback:init/1 returns 'post_init', Callback:post_init/1 is called to perform the genuine initialization work. This is to avoid crashes in Callback:init/1 which may prevent the parent supervisor from restarting it.

  8. Call os:timestamp/0 and timer:now_diff/2 for timestamps.

  9. Ignore delayed retry in MaxR accumulation.

  10. Use specs by default

Modifications 1-5 are (C) 2010-2013 GoPivotal, Inc.

Modifications 6-10 are (C) 2015-2016 Klarna AB

supervisor3's People

Contributors

dumbbell avatar michaelklishin avatar videlalvaro avatar zmstone avatar id avatar binarin avatar essen avatar deadtrickster avatar ayanda-d avatar fenollp avatar

Watchers

James Cloos 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.