Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 172257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:08:01+00:00 2026-05-11T13:08:01+00:00

Problem: I want to implement several php-worker processes who are listening on a MQ-server

  • 0

Problem: I want to implement several php-worker processes who are listening on a MQ-server queue for asynchronous jobs. The problem now is that simply running this processes as daemons on a server doesn’t really give me any level of control over the instances (Load, Status, locked up)…except maybe for dumping ps -aux. Because of that I’m looking for a runtime environment of some kind that lets me monitor and control the instances, either on system (process) level or on a higher layer (some kind of Java-style appserver)

Any pointers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:08:01+00:00Added an answer on May 11, 2026 at 1:08 pm

    Here’s some code that may be useful.

    <? define('WANT_PROCESSORS', 5); define('PROCESSOR_EXECUTABLE', '/path/to/your/processor'); set_time_limit(0); $cycles = 0; $run = true; $reload = false; declare(ticks = 30);  function signal_handler($signal) {     switch($signal) {     case SIGTERM :         global $run;         $run = false;         break;     case SIGHUP  :         global $reload;         $reload = true;         break;     }    }  pcntl_signal(SIGTERM, 'signal_handler'); pcntl_signal(SIGHUP, 'signal_handler');  function spawn_processor() {     $pid = pcntl_fork();     if($pid) {         global $processors;         $processors[] = $pid;     } else {         if(posix_setsid() == -1)             die('Forked process could not detach from terminal\n');         fclose(stdin);         fclose(stdout);         fclose(stderr);         pcntl_exec(PROCESSOR_EXECUTABLE);         die('Failed to fork ' . PROCESSOR_EXECUTABLE . '\n');     } }  function spawn_processors() {     global $processors;     if($processors)         kill_processors();     $processors = array();     for($ix = 0; $ix < WANT_PROCESSORS; $ix++)         spawn_processor(); }  function kill_processors() {     global $processors;     foreach($processors as $processor)         posix_kill($processor, SIGTERM);     foreach($processors as $processor)         pcntl_waitpid($processor);     unset($processors); }  function check_processors() {     global $processors;     $valid = array();     foreach($processors as $processor) {         pcntl_waitpid($processor, $status, WNOHANG);         if(posix_getsid($processor))             $valid[] = $processor;     }     $processors = $valid;     if(count($processors) > WANT_PROCESSORS) {         for($ix = count($processors) - 1; $ix >= WANT_PROCESSORS; $ix--)             posix_kill($processors[$ix], SIGTERM);         for($ix = count($processors) - 1; $ix >= WANT_PROCESSORS; $ix--)             pcntl_waitpid($processors[$ix]);     } elseif(count($processors) < WANT_PROCESSORS) {         for($ix = count($processors); $ix < WANT_PROCESSORS; $ix++)             spawn_processor();     } }  spawn_processors();  while($run) {     $cycles++;     if($reload) {         $reload = false;         kill_processors();         spawn_processors();     } else {         check_processors();     }     usleep(150000); } kill_processors(); pcntl_wait(); ?> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 96k
  • Answers 96k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OK, I found the solution. I happened to be calling… May 11, 2026 at 7:10 pm
  • Editorial Team
    Editorial Team added an answer JPL is no longer an additional download, so you don't… May 11, 2026 at 7:10 pm
  • Editorial Team
    Editorial Team added an answer Just tested a DISTINCT query on a table that contains… May 11, 2026 at 7:10 pm

Related Questions

I want to implement a two-pass cache system: The first pass generates a PHP
Here's the problem I'm having, I've got a set of logs that can grow
I have a webapp development problem that I've developed one solution for, but am
Brief description of requirements (Lots of good answers here, thanks to all, I'll update

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.