All Projects → kbrw → delayed_otp

kbrw / delayed_otp

Licence: other
Delay death of supervisor children or gen_server : for instance Erlang supervisor with exponential backoff restart strategy

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to delayed otp

Multivisor
Centralized supervisor WebUI and CLI
Stars: ✭ 104 (+372.73%)
Mutual labels:  supervisor
Cedardeploy
cedardeploy:发布系统基于python,flask,mysql,git,ssh-key,supervisor.支持多类型,上线,回滚,监控,报警
Stars: ✭ 248 (+1027.27%)
Mutual labels:  supervisor
balena-node-red
a node-red application with balena-supervisor support, can be managed remotely via balena publicURL
Stars: ✭ 54 (+145.45%)
Mutual labels:  supervisor
Monexec
Light supervisor on Go (with optional Consul autoregistration)
Stars: ✭ 132 (+500%)
Mutual labels:  supervisor
Flask Easy Template
A template web app with Flask. Features: latest bootstrap, user registry, login, forgot password. Secured admin panel, pagination, config files for Nginx and Supervisor and much more.
Stars: ✭ 154 (+600%)
Mutual labels:  supervisor
SupervisorXMLRPC
Simple Supervisor XML RPC Client in PHP
Stars: ✭ 30 (+36.36%)
Mutual labels:  supervisor
Earl
Service Objects for Crystal (Agents, Artists, Supervisors, Pools, ...)
Stars: ✭ 89 (+304.55%)
Mutual labels:  supervisor
supervisor
[Mirror] Supervisor trees for Go applications.
Stars: ✭ 35 (+59.09%)
Mutual labels:  supervisor
Supervisor
PHP library for managing Supervisor through XML-RPC API
Stars: ✭ 163 (+640.91%)
Mutual labels:  supervisor
tutorials
Collection of tutorials for various libraries and technologies
Stars: ✭ 98 (+345.45%)
Mutual labels:  supervisor
Ssr Manyuser glzjin shell
sspanel v3 魔改版 后端一键安装配置管理脚本
Stars: ✭ 133 (+504.55%)
Mutual labels:  supervisor
Homebridge Config Ui X
The Homebridge UI. Monitor, configure and backup Homebridge from a browser.
Stars: ✭ 1,967 (+8840.91%)
Mutual labels:  supervisor
elfo
Your next actor system
Stars: ✭ 38 (+72.73%)
Mutual labels:  supervisor
Graceful
graceful reload golang http server, zero downtime, compatible with systemd, supervisor
Stars: ✭ 129 (+486.36%)
Mutual labels:  supervisor
admin-training
Galaxy Admin Training
Stars: ✭ 55 (+150%)
Mutual labels:  supervisor
Supervisor Event Listener
Supervisor事件通知, 支持邮件, Slack, WebHook
Stars: ✭ 95 (+331.82%)
Mutual labels:  supervisor
golet
*.go file as a mini supervisor
Stars: ✭ 60 (+172.73%)
Mutual labels:  supervisor
lnmp-docker
Docker for LNMP ( Alpine Linux + PHP7 + Nginx+ Supervisor + Crontab ) 开发环境镜像
Stars: ✭ 23 (+4.55%)
Mutual labels:  supervisor
docker-alpine
Minimal Alpine with working init process
Stars: ✭ 21 (-4.55%)
Mutual labels:  supervisor
director
Director is a production-ready supervisor and manager for Erlang/Elixir processes that focuses on speed, performance and flexibility.
Stars: ✭ 62 (+181.82%)
Mutual labels:  supervisor

DelayedOTP

DelayedSup and DelayedServer are respectively Supervisor and GenServer but with the capability to delay the death of the child or the server to have a better supervision restart time control.

With exactly the same API as Supervisor, create a supervisor which allows you to control a minimum delay for the supervised children to die.

You can for instance :

  • get an Exponential backoff restarting strategy for children
  • normalized death time for port managed external processes

Useful to manage external service in Elixir supervisors.

Usage

All the same as Supervisor, but a new option is available: :delay_fun which is a function returning the minimum lifetime of a child in millisecond (child death will be delayed if it occurs too soon).

The signature of :delay_fun is: (child_id :: term, ms_lifetime :: integer, acc :: term) -> {ms_delay_death :: integer, newacc:: term} First start accumulator is nil.

Below an example usage with an exponential backoff strategy: (200*2^count) ms delay where the backoff count is reset when previous run lifetime was > 5 secondes.

import DelayedSup.Spec
import Bitwise
@reset_backoff_lifetime 5_000
@init_backoff_delay 200
DelayedSup.start_link([
  worker(MyServer1,[]),
  worker(MyServer2,[])
], restart_strategy: :one_for_one, 
   delay_fun: fn _id,lifetime,count_or_nil->
               count = count_or_nil || 0
               if lifetime > @reset_backoff_lifetime, 
                 do: {0,0}, 
                 else: {@init_backoff_delay*(1 <<< count),count+1}
          end)

How it works

The created "supervisor" creates actually the following supervision tree :

supervise([child1,child2], strategy: :one_for_one) =>

+--------------+       +----------+      +---------+
| Supervisor   +------>+TempServer+----->+ Child1  |
+--------------+       +----------+      +---------+
               |       +----------+      +---------+
               +------>+TempServer+----->+ Child2  |
                       +----------+      +---------+

TempServer (actually DelayedServer) is an intermediate process which can delay its death relatively to its linked server.

Restart Counter, and delay computation function are kept into the supervisor process dictionnary.

The shutdown strategy (brutal kill or max shutdown duration) is handled by the temp server.

Installation

If available in Hex, the package can be installed as:

  1. Add delayed_otp to your list of dependencies in mix.exs:

    def deps do [{:delayed_otp, "~> 0.0.1"}] end

  2. Ensure delayed_otp is started before your application:

    def application do [applications: [:delayed_otp]] end

CONTRIBUTING

Hi, and thank you for wanting to contribute. Please refer to the centralized informations available at: https://github.com/kbrw#contributing

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].