【问题标题】:504 Gateway Time-out error on Laravel Forge scheduled taskLaravel Forge 计划任务上的 504 网关超时错误
【发布时间】:2018-01-09 07:36:33
【问题描述】:

我使用 Laravel Forge 部署了一个旧的自定义 PHP 应用程序,并且有几个计划任务无法运行。我尝试从终端运行它们,对于这个命令wget https://app/cronjobs/get-provider-stats,我得到以下输出:

--2017-08-02 10:30:47--  https://app/cronjobs/get-provider-stats
Resolving app (app)... 46.xxx.xxx.xxx
Connecting to app (app)|46.xxx.xxx.xxx|:443... connected.
HTTP request sent, awaiting response... 504 Gateway Time-out
Retrying.

--2017-08-02 10:31:48--  (try: 2)  https://app/cronjobs/get-provider-stats
Reusing existing connection to app:443.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: ‘get-provider-stats’

get-provider-stats 文件中有 504 网关超时 HTML 页面内容。

我还检查了 nginx 日志,输出如下:

2017/08/02 10:32:48 [error] 4342#4342: *438 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 46.xxx.xxx.xxx, server: app, request: "GET /cronjobs/get-provider-stats HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.1-fpm.sock", host: "app"

我尝试更改 PHP CLI 配置,如下所示:

max_inputution_time = 300 (from 30)
max_input_time = 600 (from 60)

但这并没有解决我的问题。任何想法我还能尝试什么?

【问题讨论】:

  • 请检查 nginx 配置中是否有 fastcgi_read_timeout 等参数。看来您的 php 运行时间比 nginx 想要读取的时间长 - 如果我做对了。
  • 我在 nginx 配置 fastcgi_read_timeout 300; 中添加了以下行。现在我收到另一个错误:ERROR 502: Bad Gateway 和 nginx 日志有以下消息 1849#1849: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 46.xxx.xxx.xxx, server: app, request: "GET /cronjobs/get-provider-stats HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.1-fpm.sock:", host: "app"
  • 好吧,抱歉,这是一个假设......(你重新启动了 nginx?)也许这会有所帮助:serverfault.com/questions/543999/…
  • 我也重启了 nginx 和 PHP。我还增加了pm.max_requestsrequest_terminate_timeout
  • 你解决过这个问题吗?我得到了同样的错误

标签: php nginx


【解决方案1】:

这不是超时问题。

请重新检查您的 cron 命令。

因为它没有得到任何响应,所以抛出 504。

尝试指定 cron 选项..

【讨论】:

    猜你喜欢
    • 2018-10-23
    • 2017-08-02
    • 1970-01-01
    • 2011-04-08
    • 2017-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-04
    相关资源
    最近更新 更多