Coder Social home page Coder Social logo

devgroup-ru / yii2-deferred-tasks Goto Github PK

View Code? Open in Web Editor NEW
11.0 18.0 5.0 73 KB

Yii2 extension for handling deferred tasks (background cron jobs)

License: BSD 3-Clause "New" or "Revised" License

PHP 87.68% Shell 0.37% JavaScript 11.16% Batchfile 0.79%
yii2-deferred-tasks deferred-tasks cron yii2 queue background-jobs

yii2-deferred-tasks's Introduction

yii2-deferred-tasks's People

Contributors

bethrezen avatar moglazkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

yii2-deferred-tasks's Issues

Long tasks lead to MySQL has gone away

How to catch the error:

  1. Create very long task(more then connection timeout in mysql)
  2. When task is done - deferred-tasks tries to update DeferredQueue record
  3. MySQL has gone away and closed connection

How to fix:
Reopen connection to MySQL after task process exited.
In deep - before https://github.com/DevGroup-ru/yii2-deferred-tasks/blob/master/src/commands/DeferredController.php#L232 and https://github.com/DevGroup-ru/yii2-deferred-tasks/blob/master/src/commands/DeferredController.php#L251 we need to add something like:

Yii::$app->db->close();
Yii::$app->db->open();

This construction should be in separate function.

Also, please check if this error appears on persistent connections(see this issue on how to configure it). If it is so - check for persistent connection and don't reconnect.

Automatic HOME directory detection

On posix systems we can try to call posix_getpwuid:

php > var_dump(posix_getpwuid(posix_getuid()));
array(7) {
  'name' =>
  string(9) "bethrezen"
  'passwd' =>
  string(8) "********"
  'uid' =>
  int(501)
  'gid' =>
  int(20)
  'gecos' =>
  string(21) "Alexander Kozhevnikov"
  'dir' =>
  string(16) "/Users/bethrezen"
  'shell' =>
  string(8) "/bin/zsh"
}

Home directory is in dir.
Some additional checks like if we running posix OS or if dir is filled are needed too.
If we haven't set home directory with Yii::$app->params['deferred.env'] and it is determined with such method - use it.

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.