Skip to content

Worker->fork() not working when pcntl isn't installed #98

@ruudk

Description

@ruudk

I just found out that my production server doesn't have PCNTL installed. Now every job is accepted but not executed:

// Resque/Worker.php

// On my server, this returns -1 because it isn't installed
$this->child = Resque::fork();

// So here, it isn't executed, because it isn't 0 nor false
if ($this->child === 0 || $this->child === false) {
    $status = 'Processing ' . $job->queue . ' since ' . strftime('%F %T');
    $this->updateProcLine($status);
    $this->log($status, self::LOG_VERBOSE);
    $this->perform($job);
    if ($this->child === 0) {
        exit(0);
    }
}

// This isn't executed either... because its below 0 
if($this->child > 0) {
    // Parent process, sit and wait
    $status = 'Forked ' . $this->child . ' at ' . strftime('%F %T');
    $this->updateProcLine($status);
    $this->log($status, self::LOG_VERBOSE);

    // Wait until the child process finishes before continuing
    pcntl_wait($status);
    $exitStatus = pcntl_wexitstatus($status);
    if($exitStatus !== 0) {
        $job->fail(new Resque_Job_DirtyExitException(
            'Job exited with exit code ' . $exitStatus
        ));
    }
}

$this->child = null;

// Wtf?? Didn't do anythin' ;)
$this->doneWorking();

So what would be the best way to fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions