Horizon: ERROR: A non-numeric value encountered

Created on 22 May 2019  ·  16Comments  ·  Source: laravel/horizon

  • Horizon Version: 3.2.1
  • Laravel Version: 5.7.28
  • PHP Version: 7.1.26
  • Redis Driver & Version: predis 1.1.1
  • Database Driver & Version: mysql 5.7

Description:

When launching php artisan horizon, after the installation steps listed in the documentation, the system works but keeps throwing this Exception every second or so:

{
   "class": "ErrorException",
   "message": "A non-numeric value encountered",
   "code": 0,
   "file": "\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1682",
   "trace": [
       "\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1682",
       "{\"function\":\"Illuminate\\\\Support\\\\{closure}\",\"class\":\"Illuminate\\\\Support\\\\Collection\",\"type\":\"->\",\"args\":[0,{\"cpu\":0.47,\"mem\":\"www\"}]}",
       "\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1415",
       "\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1683",
       "\/var\/www\/vendor\/laravel\/horizon\/src\/Repositories\/RedisSupervisorRepository.php:129",
       "{\"function\":\"Laravel\\\\Horizon\\\\Repositories\\\\{closure}\",\"class\":\"Laravel\\\\Horizon\\\\Repositories\\\\RedisSupervisorRepository\",\"type\":\"->\",\"args\":[\"[object] (Predis\\\\Pipeline\\\\Pipeline)\"]}",
       "\/var\/www\/vendor\/predis\/predis\/src\/Pipeline\/Pipeline.php:211",
       "\/var\/www\/vendor\/predis\/predis\/src\/Client.php:445",
       "\/var\/www\/vendor\/predis\/predis\/src\/Client.php:396",
       "\/var\/www\/vendor\/predis\/predis\/src\/Client.php:418",
       "\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Redis\/Connections\/Connection.php:114",
       "\/var\/www\/vendor\/laravel\/framework\/src\/Illuminate\/Redis\/Connections\/Connection.php:214",
       "\/var\/www\/vendor\/laravel\/horizon\/src\/Repositories\/RedisSupervisorRepository.php:138",
       "\/var\/www\/vendor\/laravel\/horizon\/src\/Supervisor.php:354",
       "\/var\/www\/vendor\/laravel\/horizon\/src\/Supervisor.php:308",
       "\/var\/www\/vendor\/laravel\/horizon\/src\/Supervisor.php:267",
       "\/var\/www\/vendor\/laravel\/horizon\/src\/Console\/SupervisorCommand.php:92",
       "\/var\/www\/vendor\/laravel\/horizon\/src\/Console\/SupervisorComman…

I was able to fix it temporarily by updating
vendor/laravel/horizon/src/SystemProcessCounter.php at line 33:

return ['cpu' => $row->first() / 100, 'mem' => $row->last()];

to

return ['cpu' => $row->first() / 100, 'mem' => (float)$row->last()];

It probably can be fixed in a better way, but that's the spot where it was breaking, by sending 0.00 instead of "0.00".
Looking forward to an update to avoid having to manually change my vendor files. O_o :D

Steps To Reproduce:

  • Install Redis
  • Install Horizon
  • Launch php artisan horizon
bug

Most helpful comment

A little more digging here shows that https://github.com/gliderlabs/docker-alpine/issues/173#issuecomment-218620191 contains the answer for alpine linux users. Why this has worked for me up until this point I don't know.

The default ps in the image is a BusyBox command. You need to install procps to get the ps you are expecting:

apk --no-cache add procps

All 16 comments

Same here

We started seeing this yesterday in alpine v3.8.2. For me, the mem is coming through as "www-data". The stats output is shown below:

queue_1         |    32 www-data  0:00 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 --queue=reporting --sleep=3 --timeout=60 --tries=3 --supervisor=328090ae96fc-6xA8:supervisor-1
queue_1         |    33 www-data  0:00 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 --queue=notify-guilds --sleep=3 --timeout=60 --tries=3 --supervisor=328090ae96fc-6xA8:supervisor-1
queue_1         |    34 www-data  0:00 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 --queue=pin-message --sleep=3 --timeout=60 --tries=3 --supervisor=328090ae96fc-6xA8:supervisor-1
queue_1         |    35 www-data  0:00 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 --queue=delete-messages --sleep=3 --timeout=60 --tries=3 --supervisor=328090ae96fc-6xA8:supervisor-1
queue_1         |    36 www-data  0:00 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 --queue=check-games --sleep=3 --timeout=60 --tries=3 --supervisor=328090ae96fc-6xA8:supervisor-1

In alpine 3.8.2 the format seems to have no effect... :

/var/www/html # ps axo %cpu,%mem,command
PID   USER     TIME  COMMAND
    1 root      0:00 s6-svscan -t0 /var/run/s6/services
   34 root      0:00 s6-supervise s6-fdholderd
  175 root      0:00 s6-supervise nginx
  176 root      0:00 s6-supervise php-fpm
  178 root      0:00 php-fpm: master process (/usr/local/etc/php-fpm.conf)
  179 root      0:00 {run} /bin/sh ./run
  181 root      0:00 nginx: master process nginx -g daemon off;

In Ubuntu 16.04 the output seems correct:

%CPU %MEM COMMAND
 0.0  0.4 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 -
 0.0  0.4 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 -
 0.0  0.4 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 -
 0.0  0.4 /usr/local/bin/php artisan horizon:work redis --delay=0 --memory=128 -

A little more digging here shows that https://github.com/gliderlabs/docker-alpine/issues/173#issuecomment-218620191 contains the answer for alpine linux users. Why this has worked for me up until this point I don't know.

The default ps in the image is a BusyBox command. You need to install procps to get the ps you are expecting:

apk --no-cache add procps

/ping @AJenbo

The reason that it has worked previously with the BusyBox versions of ps (what is installed by default in Alpine) is that it ignores invalid (unsupported) arguments and just gives you the default. The reason it has worked previously is that Horizon only cared about the line containing the command, but now that it parses the output it needs to actually be what was requested.

The right solution like @bkuhl suggested is to install a more featureful version of ps, of cause it would be nice if it fails gracefully. @driesvints would you be ok with it showing 0.00 when a supported version of ps is not used, or should I try to make it so that it shows -- or Unsupported in the UI?

I think Unsupported would be good, but it'd be ideal if it provided some guidance on how to resolve it via a tooltip or link to this issue.

Here is what I have in mind:
image

Sounds great to me!

The two dashes is fine. Feel free to send in a PR.

I personally love spamming bugsnag with a regression.

@robclancy does upgrading to v3.2.2 help? A fix for this was merged in here: https://github.com/laravel/horizon/pull/606

I'm keeping open this issue btw for this feature request: https://github.com/laravel/horizon/issues/597#issuecomment-495697594

Feel free to PR that in.

But the numeric issue should be fixed in v3.2.2

597 only solves the issues for system where the ps version supports the output format, but the system language is set to a locale that uses , as the fraction separator.

This issue relates to systems where the installed ps doesn't support the requested output. I unfortunately haven't haven't had the needed time to work on the issues as there has been more pressing matters, but hope to have time in about a weeks time.

In light of the bugs in the last couple of weeks and the performance hit we've decided to revert the original PR. Please see my answer here: https://github.com/laravel/horizon/pull/589#issuecomment-502085735

i have a some problem please help me not show my login page how can I solve that??
image
image

helpers/captcha_helper.php line -96
if (($name + $expiration) < $now)
{
@unlink($img_path.$filename);
}
}
}

@sayeedazmal your issue doesn't appear to be related to this topic (or even Laravel Horizon). My guess would be that $name is either not a number or maybe even the wrong variable being used.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tillkruss picture tillkruss  ·  6Comments

francislavoie picture francislavoie  ·  5Comments

mahdiahmadi73 picture mahdiahmadi73  ·  3Comments

okaufmann picture okaufmann  ·  3Comments

sojeda picture sojeda  ·  5Comments