Coder Social home page Coder Social logo

php-supervisor-status-checker's Introduction

Supervisor Status Checker

Simple tool to check supervisor's processes statuses. You can receive events on process FATAL error and, for example, send a notification to yourself.

Installation

composer require sergeich5/php-supervisor-status-checker

Usage

  1. Create your own class and extend it from \Sergeich5\SupervisorStatusChecker\Callback\CallbackHandler or implement from \Sergeich5\SupervisorStatusChecker\Callback\CallbackHandlerInterface
<?php

// MyCallbackHandler.php

class MyCallbackHandler extends \Sergeich5\SupervisorStatusChecker\Callback\CallbackHandler
{
    function onBeforeTick()
    {
        // YOUR LOGIC HERE
    }

    function onAfterTick()
    {
        // YOUR LOGIC HERE
    }
    
    function onFatal(string $processName)
    {
        // YOUR LOGIC HERE
    }

    function onRunning(string $processName)
    {
        // YOUR LOGIC HERE
    }

    function onStarting(string $processName)
    {
        // YOUR LOGIC HERE
    }

    function onBackoff(string $processName)
    {
        // YOUR LOGIC HERE
    }

    function onStopped(string $processName)
    {
        // YOUR LOGIC HERE
    }

    function onUnknown(string $processName, string $status)
    {
        // YOUR LOGIC HERE
    }
}
  1. Implement necessary events and do your logic

  2. Create an instance of \Sergeich5\SupervisorStatusChecker\Checker and provide an instance of MyCallbackHandler, checking delay in seconds, event logic and debug/no-debug mode

$loop = new \Sergeich5\SupervisorStatusChecker\Checker(
    new MyCallbackHandler(),
    true,
    false
);
  1. Call method checkLoop(int DELAY_IN_SECONDS) for automatically check
$loop->checkLoop( int DELAY_IN_SECONDS );

or checkOnce() for one-time check

$loop->checkOnce();

php-supervisor-status-checker's People

Contributors

sergeich5 avatar sergeich5w avatar

Watchers

 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.