brianlmoon / GearmanManager

PHP daemon for managing gearman workers
http://brian.moonspot.net/GearmanManager
BSD 2-Clause "Simplified" License
682 stars 190 forks source link

getopt empty #113

Closed NanoCaiordo closed 9 years ago

NanoCaiordo commented 9 years ago

Hello, I've recently installed GearmanManager on a CloudLinux Server release 6.6 X-Powered-By PHP/5.4.39 and it wasn't able to find the ./workers dir. I soon realized that none of the parameters was passed to the script.

/etc/rc.d/init.d/gearman-manager correctly try to daemonize the script with deamon --pidfile=/var/run/gearman/manager.pid /usr/local/bin/gearman-manager -P /var/run/gearman/manager.pid -l /var/log/gearman-manager.log -u gearmand -d -c /etc/gearman-manager/config.ini

In /usr/local/share/gearman-manager/pecl-manager.php I've then placed exit(var_dump(getopt("ac:dD:h:Hl:o:p:P:u:v::w:r:x:Z"))); and its output is:

bool(false)

However exit(var_dump($argv)); outputs:

array(10) {
  [0] => string(30) "/usr/local/bin/gearman-manager"
  [1] => string(2) "-P"
  [2] => string(28) "/var/run/gearman/manager.pid"
  [3] => string(2) "-l"
  [4] => string(28) "/var/log/gearman-manager.log"
  [5] => string(2) "-u"
  [6] => string(8) "gearmand"
  [7] => string(2) "-d"
  [8] => string(2) "-c"
  [9] => string(31) "/etc/gearman-manager/config.ini"
}
brianlmoon commented 9 years ago

Hmm, I don't know why that would return false. The PHP docs say it returns false on failure, but does not really say why getopt would fail. http://php.net/getopt#refsect1-function.getopt-returnvalues

Can you try adding error_reporting(-1) to the file to show what PHP errors may be ocurring?

NanoCaiordo commented 9 years ago
error_reporting(-1);
ini_set('error_log', '/var/log/gearman-manager.log');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
exit(var_dump(getopt("ac:dD:h:Hl:o:p:P:u:v::w:r:x:Z")));

No errors on script start up apart the usual bool(false) and cat /var/log/gearman-manager.log is still empty (thus I did make sure that error_log('test') successfully wrote to gearman-manager.log which it did).

conradjones commented 9 years ago

IIRC you need to set -v or -vv or -vvv in the params line in the init.d script

e.g. my init.d script for one of my workers contains this line.

PARAMS="-c ${CONFIGDIR}/config.ini -vvv"

On Thu, Apr 9, 2015 at 12:10 AM, Marco Pannetto notifications@github.com wrote:

error_reporting(-1); ini_set('error_log', '/var/log/gearman-manager.log'); ini_set('display_errors', 1); ini_set('display_startup_errors', 1);

cat /var/log/gearman-manager.log is still empty (thus I did make sure that error_log('test') successfully wrote to gearman-manager.log which it did).

— Reply to this email directly or view it on GitHub https://github.com/brianlmoon/GearmanManager/issues/113#issuecomment-91063948 .

NanoCaiordo commented 9 years ago

Same problem, -vvv doesn't enable any verbose debugging.

conradjones commented 9 years ago

The options go all the way up to -vvvvv try that first and then work backwards.

On Fri, Apr 10, 2015 at 5:32 AM, Marco Pannetto notifications@github.com wrote:

Same problem, -vvv doesn't enable any verbose debugging.

— Reply to this email directly or view it on GitHub https://github.com/brianlmoon/GearmanManager/issues/113#issuecomment-91426008 .

NanoCaiordo commented 9 years ago

Nothing to do, but if I execute /usr/local/bin/gearman-manager -P /var/run/gearman/manager.pid -l /var/log/gearman-manager.log -u gearmand -d -c /etc/gearman-manager/config.ini then getopt() is properly filled. It is clear to me that daemon doesn't let pass any parameter and logs are empty from relevant data.

NanoCaiordo commented 9 years ago

Gearman-manager is not the issue, I've created a start up script and a php file and the problem persist. I'm closing this issue and opened one at php.net https://bugs.php.net/bug.php?id=69421

Cheers

conradjones commented 9 years ago

Can you not upgrade your version of PHP? I'm running 5.6.7-1 here.

On Fri, Apr 10, 2015 at 6:34 PM, Marco Pannetto notifications@github.com wrote:

Gearman-manager is not the issue, I've created a start up script and a php file and the problem persist. I'm closing this issue and opened one at php.net https://bugs.php.net/bug.php?id=69421

Cheers

— Reply to this email directly or view it on GitHub https://github.com/brianlmoon/GearmanManager/issues/113#issuecomment-91630628 .

NanoCaiordo commented 9 years ago

Upgrading to 5.5 was enough to fix it. Thank you.