Git Product home page Git Product logo

cavalcade-runner's Introduction

Cavalcade-Runner
Daemon for Cavalcade, a scalable WordPress jobs system.
Build status
A Human Made project. Maintained by @rmccue.

What?

This is the runner for Cavalcade. Head over to the Cavalcade repo to learn more about running this.

cavalcade-runner's People

Contributors

rmccue avatar harai avatar joehoyle avatar nathanielks avatar onnimonni avatar dd32 avatar roborourke avatar swissspidy avatar kraftbj avatar schlessera avatar ocean90 avatar discoinfiltrator avatar jeremyfelt avatar willmot avatar

Watchers

James Cloos avatar  avatar

cavalcade-runner's Issues

Fix "MySQL server has gone away" error

Fix endless "MySQL server has gone away" error:

{
    "timestamp": "2022-01-03T10:33:20.973+0000",
    "level": "ERROR",
    "type": "infra",
    "version": "build-55",
    "message": "database error",
    "dump": "",
    "err_content": [
        "HY000",
        2006,
        "MySQL server has gone away"
    ]
}
{
    "timestamp": "2022-01-03T10:33:20.973+0000",
    "level": "ERROR",
    "type": "infra",
    "version": "build-55",
    "message": "failed to get next job",
    "ex_message": "database error"
}

Fix invalid callback error

{
    "timestamp": "2023-01-17T05:48:11.488+0000",
    "level": "ERROR",
    "type": "infra",
    "version": "build-85",
    "message": "exception during starting job",
    "ex_message": "PHP error ocurred: Invalid callback HM\\Cavalcade\\Runner\\Runner::terminate_by_signal, cannot access protected method HM\\Cavalcade\\Runner\\Runner::terminate_by_signal()"
}

PHPファイルの読み込みでサイドエフェクトが発生しないようにする

PHPに限らず、処理と定義をわける→ Avoid Side effect

https://github.com/tarosky/Cavalcade-Runner/blame/677586e48f0ff502328a9fa8bed42c0c3c5d513e/inc/healthcheck-eip.php#L20

値を保持したい場合は、クラスにしてメンバー変数などにするか、関数の場合は static変数 を使う

/**
 * トークンを取得する
 * @return string
 * @throw Exception
 */
function get_token() {
    static $token = null;
    static $tried   = 0;
    if ( is_null( $token ) ) {
         // まだ実行されてない?
        if ( ! $tried ) {
            $tried++;
            $token = get_fresh_token();
        } elseif ( $tried < MAX_RETRY ) {
            // まだリトライ可能
            $tried++;
            $token = renew_token( $token ); // renew_token は失敗するとnullを返す
        } else {
             trow new Exception( 'トークンが取れませんでした。' );
        }
    }
    return $token;
}

あとは呼び出し側を工夫するか、ジェネレータ を使うかなどとして、トークンを利用する処理が「最大3回までリトライを許容しつつトークン取得を試み続ける」という使い方をすればよいと思います。

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.