Giter Site home page Giter Site logo

Comments (3)

phuze avatar phuze commented on September 26, 2024

Hi Dave,

Please post code inside of code tags; its not pleasant trying to read that mate.

The behaviour you are describing, admittedly, doesn't make much sense. Just to confirm, are you running this through cli mode?

Are you using tasks, or workers?

What does your daemon execute() function look like?

from php-daemon.

phuze avatar phuze commented on September 26, 2024

Upon inspecting the code you tried to post above, i see syntax errors and logic that I don't understand. Why delete the log file every time? You are also trying to execute your code inside a condition based on the existence of a log file which won't exist the second time around since you're deleting it. There's a lot of reasons why your code is failing here.

Did you take a look at the the examples?

logfile = __DIR__ . '/../logs/migrate_posts_service.log';
$this->pidfile = __DIR__ . '/../locks/ALO_Client_Daemon_Migrate_Posts.pid';

if (file_exists($this->logfile))
    unlink($this->logfile);
    $this->mp = ALO_CLI_Daemon_Migrate_Posts::getInstance()
    ->setDaemonize(false)
    ->setLoopInterval(20)
    ->setVerbose(true)
    ->setDebug(true)
    ->setDebugLevel(3)
    ->setLogFile($this->logfile)
    ->run();
    echo "Finished setUp()\n";
}

from php-daemon.

lifo101 avatar lifo101 commented on September 26, 2024

If your code is separated into pieces of logic, then you should be able to unit test things w/o even using the Daemon itself. Your unit tests would simply create instances of your objects and call methods you want to test. All, w/o even creating a Daemon instance.

For instance, if you have a worker you want to test, simply create the Worker in your unit test, call whatever methods you need, check the result and move on.

Testing your main daemon loop logic will be harder and I have no suggestions for that. Generally, the logic in your main daemon loop should be as simple as polling a resource for some event to act on. All of your workers and task objects will be what handles the actual work load, which is where most of your testing will be.

from php-daemon.

Related Issues (20)

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.