I have a MySQL database with a table called events. Each event has a time associated with it - it should be processed precisely at that time - to the second.
The core of my system (that gerenerates all these events) is php based, so I think the best way of processing these events will be a php daemon/service.
(1) What is the best place to start when thinking about building a php daemon/service?
(2) Are there libraries that will work on Windows AND Linux? Or will the control structures have to be completely different.
(3) I'd like this to be able to be multi-threaded. Is this possible?
(4) I don't want to be on the bleeding edge. If there are de facto solutions out there I'd love to know about them.
(5) I think these should be in php as there is a reasonable amount of business logic associated with processing these events. Is this a correct assumptiuon - I mean could this be handled entirely by some feature of MySQL?
Multithreading with PHP is not really possible. I've read that the only way to accomplish it is to have one php script run several shell commands, calling each of the other scripts in the background, but people have had problems with this as well...
In order to create a script to do what you're describing, it seems like the script will need to be running all the time and be set to sleep when it's not running anything. The simplest way to do this would be to set it up so that when it completes a task, it calculates the number of seconds until the next task, and goes to sleep for that many seconds. However, if that method is used and the server is reset or something... then you're out of luck. The only way I know of doing that reliably is to set up the cron (I'm not sure how in windows) to run php scripts at the times you need them to run.
Sorry if I wasn't helpful :/
-Steve
"Build a man a fire and he'll be warm for a day. Set a man on fire and he'll be warm for the rest of his life."
Bookmarks