2

There is literally no usable quartz like scheduler in PHP, FML

Comments
  • 2
    It's called... write a scheduler.php which holds your jobs, or your jobs are stored in a DB and you query for them and then determine if they need to be executed or skipped on the current run.

    Attach the scheduler to a cron and let it run every minute.

    Problem solved!
  • 2
    https://github.com/pheanstalk/...

    https://github.com/beanstalkd/...

    Afaik it's one of the few existing, maintained, queue systems for PHP.

    Planet PHP an interview recently talking about Fiber RFC revived, guess that would change a lot.
  • 1
    This works except when you can't wait a whole minute for the cron. I ended up with a systemd service that consumed the beanstalked queue. But then you are dealing with long running php-scripts! So now the consumer-scrip exits every few hours with an unique exit-status that is then understood by the systemd-service which starts the consumer again.

    All of this just to do stuff in the background so the website doesn't feel slow... fucking heck.

    (This was at my previous job, but I'm still very proud of this shit-show I made!)
  • 1
    @SuspiciousBug well.

    It's one of the areas where PHP is weak(er).

    CLI / task | process stuff was always cumbersome...

    If you want a shit show ... Uuhm.

    I've seen while(true) implementations.... Self executing scripts...
    Rest calls creating a call loop with a supervisor in another language...

    Your solution sounds sane(r) to me than the shit I've seen.

    *Have a cookie*
  • 2
    Oh... Remembered another GEM.

    MySQL User defined function that executes a curl library call.

    Db had a trigger to execute the UDF on change calling a rest service.

    🙄
  • 1
    > Db had a trigger to execute the UDF on change calling a rest service

    how.. why.. how do ppl even come up with this (let alone implement it)?

    crazy D:
  • 0
    @SuspiciousBug been down the UDF path before, nothing like "why does nothing reference this code" --- how wrong I was for deleting it.
  • 0
  • 0
    @C0D4 no, problem isn't solved, I specifically wrote that I need a quartz alternative, which means scheduling with seconds resolution, not minutes like cron. I need that for deadlines implementation in sagas.

    Cron like schedulers exist but that's not what I need. Also I would prefer a scalable solution. There is a php quartz implementation but it isn't well documented and it only has mongo dB as backend, and I don't need another dB in my stack
  • 0
    @IntrusionCM I don't see how beanstalk will solve my scheduling problems. BTW it is not the only maintained queue system in PHP, look for symfony messenger and enqueue and you will find plenty of ootions
  • 0
    Using PHP for anything other than web pages is kinda questionable
Add Comment