Comments (3)
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.
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.
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)
- Documentation HOT 5
- Worker and pcntl_exec support HOT 9
- Forking Exception: Can't find PDO driver HOT 1
- Arguments to Tasks HOT 4
- what happens if a loop is still executing when the interval comes up? HOT 6
- Memory leak in workers HOT 17
- SySV Errors after a while. HOT 2
- Logging Failure after Restart HOT 1
- Premature worker death HOT 1
- Method returns current worker proc count? HOT 1
- Parameters on Task->run causing Fatal Error HOT 2
- Daemon Restart Event Hook HOT 3
- Using callable in worker initialization HOT 2
- Possible memory leak HOT 2
- Where to catch Premature worker death and processed it HOT 3
- PHP 8.x HOT 2
- Use with MQTT Server
- How do I pass variables to workers/tasks? HOT 1
- Sysv Error: Error fetching message from queue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-daemon.