0

我正在将我的 PHP 应用程序从Google App engine Standard Environment 迁移到 Flexible environment

我的应用程序与数据库和发送网格一起工作正常。但是 Cron 作业失败了。

我找不到在 GAE 灵活环境中运行 Cron 作业时错过的内容。我在此处提供了示例应用程序代码。

应用程序.yaml

runtime: php
env: flex

runtime_config:
document_root: web

handlers:

- url: /crontest
script: crontest.php

- url: .*
script: index.php

#[START env]
env_variables:
MYSQL_DBNAME: CRONDB
MYSQL_USER: root
MYSQL_PASSWORD: root123
MYSQL_CONNECTION: /cloudsql/project-id:us-central1:testphp7
#[END env]

#[START cloudsql_settings]
# Use the connection name obtained when configuring your Cloud SQL instance.
beta_settings:
cloud_sql_instances: "project-id:us-central1:testphp7"
#[END cloudsql_settings]

cron.yaml

- description: cron test
url: /crontest
schedule: every day 17:00
timezone: Asia/Kolkata

网络/连接.php

<?php    
    $con = new mysqli(null,$_SERVER['MYSQL_USER'],$_SERVER['MYSQL_PASSWORD'],$_SERVER['MYSQL_DBNAME'],null,$_SERVER['MYSQL_CONNECTION']);
?>

网页/crontest.php

<?php

include "connection.php";

$ATERM_spcallstmt="INSERT INTO SAMPLE(TEST_NO)VALUES('9876')";
$con->query($ATERM_spcallstmt);
?>

网页/index.php

<?php
echo " Test Cron in FE";
?>

创建表查询:

CREATE TABLE SAMPLE(TEST_NO VARCHAR(250));

来自 API 控制台的日志

18:57:00.000172.18.0.3 - - [02/May/2017:13:27:00 +0000] "GET /crontest.php HTTP/1.1" 404 162 "-" "AppEngine-Google; (+http://code.google.com/appengine)"
{
textPayload: "172.18.0.3 - - [02/May/2017:13:27:00 +0000] "GET /crontest.php HTTP/1.1" 404 162 "-" "AppEngine-Google; (+http://code.google.com/appengine)" "
insertId: "epwcgng8mcw86z"
resource: {…}
timestamp: "2017-05-02T13:27:00Z"
labels: {…}
logName: "projects/project-id/logs/appengine.googleapis.com%2Fstdout"
}

我得到 HTTP 404 & Cron 失败。

请帮我解决这个问题。

提前致谢。

4

1 回答 1

1

在您的情况下,cron 似乎正在尝试访问/web/crontest.php哪个路径不正确。我怀疑你还有旧的 cron 配置吗?

于 2017-05-04T23:56:20.757 回答